Answered

Simulation errors when multiplying matrices

I start a new clean answer You don't have to use the index i inside your matrix like you are doing in your code: in that way yo...

Simulation errors when multiplying matrices

I start a new clean answer You don't have to use the index i inside your matrix like you are doing in your code: in that way yo...

28 dagar ago | 0

Answered

Solving Complex Matrix Operations

You can do this in a for loop or using arrayfun % your A vector A = rand(1,1001); % dummy vector % calculation of the matr...

Solving Complex Matrix Operations

You can do this in a for loop or using arrayfun % your A vector A = rand(1,1001); % dummy vector % calculation of the matr...

29 dagar ago | 0

| accepted

Answered

Replicate values in a matrix i-1 times

Quick and dirty for loop A=[1; 4; 8; 3; 2; 6] B = []; for i = 1:length(A) B = [B; repmat(A(i),i,1)]; end You can als...

Replicate values in a matrix i-1 times

Quick and dirty for loop A=[1; 4; 8; 3; 2; 6] B = []; for i = 1:length(A) B = [B; repmat(A(i),i,1)]; end You can als...

29 dagar ago | 0

Answered

Find independent variables that minimize function

If you have only lower and upper bounds, use them directly in fmincon % your function fun = @(x) ((x(1)-real(0.5*(x(1)-(sqrt(x...

Find independent variables that minimize function

If you have only lower and upper bounds, use them directly in fmincon % your function fun = @(x) ((x(1)-real(0.5*(x(1)-(sqrt(x...

29 dagar ago | 0

| accepted

Answered

Simulation errors when multiplying matrices

Inside the loop in the first instruction Vn(:,i) is 5x1 but T is 5x5. Matlab now (starting in 2016, I guess) implicitly expands ...

Simulation errors when multiplying matrices

Inside the loop in the first instruction Vn(:,i) is 5x1 but T is 5x5. Matlab now (starting in 2016, I guess) implicitly expands ...

29 dagar ago | 0

Answered

Weighted fit using fmincon

How about to repeat the samples of the points you want to weight more?

Weighted fit using fmincon

How about to repeat the samples of the points you want to weight more?

29 dagar ago | 0

| accepted

Answered

how to find the optimal value of a matrix that minimize a function?

If I understand correctly the problem can be recast to the following A*W = B*H = F; [a11 a12; a21 a22]*[w1 w2 0 0; 0 0 w3 w4] ...

how to find the optimal value of a matrix that minimize a function?

If I understand correctly the problem can be recast to the following A*W = B*H = F; [a11 a12; a21 a22]*[w1 w2 0 0; 0 0 w3 w4] ...

30 dagar ago | 0

| accepted

Answered

plot 2 3D vectors in Matlab

% vectors a = [1 2 -3]; b = [-3 12 -13]; % starting point C0 = [0 0 0]; % put vector in a matrix, to make the code more...

plot 2 3D vectors in Matlab

% vectors a = [1 2 -3]; b = [-3 12 -13]; % starting point C0 = [0 0 0]; % put vector in a matrix, to make the code more...

ungefär en månad ago | 0

Answered

Error using sparse Index into matrix must be positive.

Simply remove "-1" from the definition of R. randi returns pseudorandom integers between 1 and the first inupt. The entries of C...

Error using sparse Index into matrix must be positive.

Simply remove "-1" from the definition of R. randi returns pseudorandom integers between 1 and the first inupt. The entries of C...

ungefär en månad ago | 0

Answered

How to solve time and space deriavtive using ode45?

Have a look at pdepe: it solves 1-D parabolic and elliptic PDEs

How to solve time and space deriavtive using ode45?

Have a look at pdepe: it solves 1-D parabolic and elliptic PDEs

ungefär en månad ago | 0

Answered

Finite Difference Matrix Help

Edit: I changed my answer including a reference and the second order derivative The coefficients for central differences of dif...

Finite Difference Matrix Help

Edit: I changed my answer including a reference and the second order derivative The coefficients for central differences of dif...

ungefär en månad ago | 0

Answered

improved Euler integration scheme (possible code error) in matlab

I think it should be "-" p(1) = (-z(1)*(1-(z(2)))); p(2) = z(2)*(1-(z(1)));

improved Euler integration scheme (possible code error) in matlab

I think it should be "-" p(1) = (-z(1)*(1-(z(2)))); p(2) = z(2)*(1-(z(1)));

ungefär en månad ago | 0

Answered

Make entries of first row and column of matrix all equal to zero.

% nullify first col B(:,1) = 0; %nullify first row B(1,:) = 0;

Make entries of first row and column of matrix all equal to zero.

% nullify first col B(:,1) = 0; %nullify first row B(1,:) = 0;

2 månader ago | 0

Answered

plot vector using complex numbers

You can use compass or quiver % your matrix A = [-3+4i;-2+5i;1+3i;6+2i;-1-8i]; % with compass figure compass(real(A),imag...

plot vector using complex numbers

You can use compass or quiver % your matrix A = [-3+4i;-2+5i;1+3i;6+2i;-1-8i]; % with compass figure compass(real(A),imag...

3 månader ago | 0

Answered

constantly receiving an error undefined function or variable z when use solve

Polynomials with a degree greater than 4 do not have explicit solutions. You can use vpa syms x y f1 = y == x^3 f2 = x^2+y^2...

constantly receiving an error undefined function or variable z when use solve

Polynomials with a degree greater than 4 do not have explicit solutions. You can use vpa syms x y f1 = y == x^3 f2 = x^2+y^2...

3 månader ago | 0

Answered

How to multiply only some column and rows for a given number?!

You are close to the answer, but you need to keep the first column % your matrix with data A = rand(2,21); % multiply all b...

How to multiply only some column and rows for a given number?!

You are close to the answer, but you need to keep the first column % your matrix with data A = rand(2,21); % multiply all b...

3 månader ago | 1

Answered

Unstable derivative approximation when steps get too small

This is expected. Look here for details https://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/

Unstable derivative approximation when steps get too small

This is expected. Look here for details https://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/

3 månader ago | 1

Answered

How to start streamlines on the surface of a sphere? griddedInterpolant requires at least two sample points in each dimension

It looks like streamline does not accepts coordinates coming from your spherical construction. If you start form a cartesian gri...

How to start streamlines on the surface of a sphere? griddedInterpolant requires at least two sample points in each dimension

It looks like streamline does not accepts coordinates coming from your spherical construction. If you start form a cartesian gri...

3 månader ago | 2

| accepted

Answered

n! permutation matrices

Is this what you wish? % identity matrix A = eye(4); % permuatations idx = perms(1:4); % all matrices in a cell array B = ...

n! permutation matrices

Is this what you wish? % identity matrix A = eye(4); % permuatations idx = perms(1:4); % all matrices in a cell array B = ...

4 månader ago | 0

Answered

Solve the system of the 1-st order differential equations

Have a look at the ode suite

Solve the system of the 1-st order differential equations

Have a look at the ode suite

4 månader ago | 0

Answered

How to make two vectors the same size?

Try fkld=sum(dot(p,log(p./q))); with the element-wise division ./

How to make two vectors the same size?

Try fkld=sum(dot(p,log(p./q))); with the element-wise division ./

4 månader ago | 1

| accepted

Answered

Inner matrix dimensions must agree

fkj= sum(.5*((p.^2-q.^2).^2)./((p.*q).^1.5)); Note that .^ .* and ./ operators are used for element-wise operation (see also St...

Inner matrix dimensions must agree

fkj= sum(.5*((p.^2-q.^2).^2)./((p.*q).^1.5)); Note that .^ .* and ./ operators are used for element-wise operation (see also St...

4 månader ago | 1

| accepted

Answered

Inverse matrix in Matlab very different to Excel

The answer is not very different. As Jeremy commented, the results are similar a part from numerical tolerances. You can verify ...

Inverse matrix in Matlab very different to Excel

The answer is not very different. As Jeremy commented, the results are similar a part from numerical tolerances. You can verify ...

4 månader ago | 1

| accepted

Answered

How to call a multi output function without repeating the run

function [c, ceq] = nonconst(x) [total_value, Delta_value, energy_value] = digital(x); c = total_value-u*v;... ` `%fi...

How to call a multi output function without repeating the run

function [c, ceq] = nonconst(x) [total_value, Delta_value, energy_value] = digital(x); c = total_value-u*v;... ` `%fi...

4 månader ago | 0

| accepted

Answered

How to color a mesh by temperature(or other value) preserving the elevation. Using two matrix(same length)

% dummy data [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X).*cos(Y); T = X+Y; % plot surf(X,Y,Z,T) colormap('hot') colorba...

How to color a mesh by temperature(or other value) preserving the elevation. Using two matrix(same length)

% dummy data [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X).*cos(Y); T = X+Y; % plot surf(X,Y,Z,T) colormap('hot') colorba...

4 månader ago | 1

| accepted

Answered

How can I get an array of velocity if I have an array of position and another array of time

First, you need a element-wise division pos = [0 2 4 8 16 32 64]; t = [0 0.1 0.2 0.3 0.4 0.5 0.6]; V = diff(pos)./diff(t); ...

How can I get an array of velocity if I have an array of position and another array of time

First, you need a element-wise division pos = [0 2 4 8 16 32 64]; t = [0 0.1 0.2 0.3 0.4 0.5 0.6]; V = diff(pos)./diff(t); ...

4 månader ago | 0

| accepted

Answered

Numerical Solution for a System of THREE Differential Equations

This is an ODE, not PDE. Look for the ODE suite

Numerical Solution for a System of THREE Differential Equations

This is an ODE, not PDE. Look for the ODE suite

4 månader ago | 0

| accepted

Answered

Area under curves with different length (trapz)

If you have the x axes for both waves, it is pretty easy to use trapz: N1 = 1036; N2 = 9958; % wave 1 x1 = linspace(0,2*pi...

Area under curves with different length (trapz)

If you have the x axes for both waves, it is pretty easy to use trapz: N1 = 1036; N2 = 9958; % wave 1 x1 = linspace(0,2*pi...

4 månader ago | 1

| accepted

Answered

Plotting the integral of a graph

Suppose that x and y are the vectors defining your waveform. % dummy values x = linspace(0,2*pi,1000); y = sin(x); % integ...

Plotting the integral of a graph

Suppose that x and y are the vectors defining your waveform. % dummy values x = linspace(0,2*pi,1000); y = sin(x); % integ...

4 månader ago | 1

| accepted

Answered

Does anybody know how to write a function which returns the coordinates of a convex hull of a list of certain points?

% your data N = 20; List = rand(N,2); % convex hull (k is the pointer to the rows in List with the convex hull k = convhul...

Does anybody know how to write a function which returns the coordinates of a convex hull of a list of certain points?

% your data N = 20; List = rand(N,2); % convex hull (k is the pointer to the rows in List with the convex hull k = convhul...

4 månader ago | 0