Answered

using mat2cell

C = mat2cell(M.',ones(1,10)); % M is your 1001x10 numerical matrix

using mat2cell

C = mat2cell(M.',ones(1,10)); % M is your 1001x10 numerical matrix

11 days ago | 0

Answered

using runge kutta RK2 on matlab

function main f = @(x,y) 5-50*y; a = 0; b = 1; n = 100; h = (b-a)/n; y(1) = 0; i = 0; for x= a:h:b-h ...

using runge kutta RK2 on matlab

function main f = @(x,y) 5-50*y; a = 0; b = 1; n = 100; h = (b-a)/n; y(1) = 0; i = 0; for x= a:h:b-h ...

11 days ago | 0

Answered

How do I loop a fucntion over matrix columns and store the results in a column?

If R is your matrix: [m,n] = size(R); H = zeros(n,1); for i = 1:n r = R(:,i); H(i) = dfaedit(r ); end

How do I loop a fucntion over matrix columns and store the results in a column?

If R is your matrix: [m,n] = size(R); H = zeros(n,1); for i = 1:n r = R(:,i); H(i) = dfaedit(r ); end

11 days ago | 0

| accepted

Answered

Script matlab calculate vectors

syms a b c A = [a b c]; B = [-2 1 -4]; C = [1 3 2]; result = [5*a+6 3*b-2 -4*c+1]; AB = cross(A,B); AC = cross(A,C); S = ...

Script matlab calculate vectors

syms a b c A = [a b c]; B = [-2 1 -4]; C = [1 3 2]; result = [5*a+6 3*b-2 -4*c+1]; AB = cross(A,B); AC = cross(A,C); S = ...

12 days ago | 0

| accepted

Answered

Using temperature and pressure data to estimate antoine coefficients for glycerol

antoine = @(b,T) 10.^( b(1) + b(2)./(T+b(3))); beta0 = [3.93737,1411.531,-200.566]; beta = nlinfit(T,p,antoine,beta0)

Using temperature and pressure data to estimate antoine coefficients for glycerol

antoine = @(b,T) 10.^( b(1) + b(2)./(T+b(3))); beta0 = [3.93737,1411.531,-200.566]; beta = nlinfit(T,p,antoine,beta0)

12 days ago | 1

Answered

Find the value of x when the first derivative is equal to 0

x = -pi/2:0.01:pi/2; y = cos(x); dydx = diff(y)./diff(x); [~,idx] = min(dydx.^2); xmin = (x(idx+1)+x(idx))/2 xmin is the po...

Find the value of x when the first derivative is equal to 0

x = -pi/2:0.01:pi/2; y = cos(x); dydx = diff(y)./diff(x); [~,idx] = min(dydx.^2); xmin = (x(idx+1)+x(idx))/2 xmin is the po...

12 days ago | 0

| accepted

Answered

How to calculate numerical integral with more than 3 variables in Matlab? ( > integral3 )

Which method is best-suited depends on the specific problem. Maybe https://de.mathworks.com/matlabcentral/fileexchange/47919-i...

How to calculate numerical integral with more than 3 variables in Matlab? ( > integral3 )

Which method is best-suited depends on the specific problem. Maybe https://de.mathworks.com/matlabcentral/fileexchange/47919-i...

12 days ago | 0

| accepted

Answered

MATLAB 2010 code not working in MATLAB2012a ?

The filename must be "testingfile.m" not "TestingFile.m" Or your function must be renamed in function [z,w] = TestingFi...

MATLAB 2010 code not working in MATLAB2012a ?

The filename must be "testingfile.m" not "TestingFile.m" Or your function must be renamed in function [z,w] = TestingFi...

12 days ago | 1

Answered

Function inside a for loop

An array of function handles is not possible. Instead, you should define s41_0 = @(a,T) a.*s_CO2(T) and evaluate it as val41...

Function inside a for loop

An array of function handles is not possible. Instead, you should define s41_0 = @(a,T) a.*s_CO2(T) and evaluate it as val41...

12 days ago | 1

Answered

How can I reshape single column vector list into equally sized matrix columns

s = mod(26599,512); n = 26599 - s; m = n/512; R = horzcat(reshape(sample_test(1:n),512,m),vertcat(sample_test(n+1:end),NaN(51...

How can I reshape single column vector list into equally sized matrix columns

s = mod(26599,512); n = 26599 - s; m = n/512; R = horzcat(reshape(sample_test(1:n),512,m),vertcat(sample_test(n+1:end),NaN(51...

13 days ago | 0

Answered

Solving a discrete logarithm problem returns a 0x1 sym or Unable to find explicit solution

Brute force: x = 0:24; y = uint64(6.^x); d = mod(y,11); x = x(d==2)

Solving a discrete logarithm problem returns a 0x1 sym or Unable to find explicit solution

Brute force: x = 0:24; y = uint64(6.^x); d = mod(y,11); x = x(d==2)

13 days ago | 0

Answered

Why do I receive this error when using cumsum: "Invalid data type. First input argument must be numeric or logical." ?

Try this: function main file_name = 'sample_test.txt'; H = dfaedit(file_name,1,1,1) end function [H]=dfaedit(file_...

Why do I receive this error when using cumsum: "Invalid data type. First input argument must be numeric or logical." ?

Try this: function main file_name = 'sample_test.txt'; H = dfaedit(file_name,1,1,1) end function [H]=dfaedit(file_...

14 days ago | 0

Answered

How can you change the bounds used by a solver with each iteration?

Use "fmincon" instead of "lsqnonlin" and change the bounds in "nonlcon".

How can you change the bounds used by a solver with each iteration?

Use "fmincon" instead of "lsqnonlin" and change the bounds in "nonlcon".

14 days ago | 0

Answered

How to plot the graph of y=ax+b?

x=0:0.1:50; y=53.5*x-1354.5; plot(x,y)

How to plot the graph of y=ax+b?

x=0:0.1:50; y=53.5*x-1354.5; plot(x,y)

14 days ago | 0

| accepted

Answered

Storing function outputs to an array so they can be plotted

A = 1:20; H_l = 2*(A+1); Sig_Lambda = 1*10^-9; I = A.*H_l*Sig_Lambda; plot(Lambda,I) works if Lambda is a sorted 1x20 ve...

Storing function outputs to an array so they can be plotted

A = 1:20; H_l = 2*(A+1); Sig_Lambda = 1*10^-9; I = A.*H_l*Sig_Lambda; plot(Lambda,I) works if Lambda is a sorted 1x20 ve...

14 days ago | 1

| accepted

Answered

how can i make a general matrix?

function main L = [1 2 0.1 0.2 0.02; ... 1 4 0.05 0.2 0.02; ... 1 5 0.08 0.3 0.03; ... 2 3 0.05 0.25 0.03; ... ...

how can i make a general matrix?

function main L = [1 2 0.1 0.2 0.02; ... 1 4 0.05 0.2 0.02; ... 1 5 0.08 0.3 0.03; ... 2 3 0.05 0.25 0.03; ... ...

14 days ago | 1

| accepted

Answered

Remove Zeros Matrix on 3D Matrix

function main val = rand(2,3,4) val(:,:,3) = [] end

Remove Zeros Matrix on 3D Matrix

function main val = rand(2,3,4) val(:,:,3) = [] end

14 days ago | 0

Answered

Plot the Poisson CDF with the Standard Normal Distribution CDF

I suspect the graphics shows that the arithmetic mean of normalized independent Poisson random variables converges in distributi...

Plot the Poisson CDF with the Standard Normal Distribution CDF

I suspect the graphics shows that the arithmetic mean of normalized independent Poisson random variables converges in distributi...

14 days ago | 0

Answered

how can i change the dimension of the matrix?

You must first decide where you want element (i,j,k) of the old matrix be placed in the new matrix. But usually MATLAB's "resha...

how can i change the dimension of the matrix?

You must first decide where you want element (i,j,k) of the old matrix be placed in the new matrix. But usually MATLAB's "resha...

14 days ago | 0

Answered

how to calculate a difference of function with any parameter

function main h = 1e-6; xleft = -pi; xright = pi; n = 200; dx = (xright-xleft)/n; x = xleft:dx:xright; chan...

how to calculate a difference of function with any parameter

function main h = 1e-6; xleft = -pi; xright = pi; n = 200; dx = (xright-xleft)/n; x = xleft:dx:xright; chan...

14 days ago | 0

Answered

Hi, I have an optimization question that should be solved with the constraints which are written. λ is a constant greater than one and ρ is total power budget that we have.

Solution is simple: rho1 = rho, rho2 = 0.

Hi, I have an optimization question that should be solved with the constraints which are written. λ is a constant greater than one and ρ is total power budget that we have.

Solution is simple: rho1 = rho, rho2 = 0.

14 days ago | 0

Answered

the projected distances between the line and edge A

You will have to check for correctness: % Project p1 on plane ABC (gives point p1-proj) Mat = [(B-A)*(B-A).' , (B-A)*(C-A).';(...

the projected distances between the line and edge A

You will have to check for correctness: % Project p1 on plane ABC (gives point p1-proj) Mat = [(B-A)*(B-A).' , (B-A)*(C-A).';(...

16 days ago | 0

| accepted

Answered

Coding a system of differential equations

Numerically solving the original system will make difficulties because of the singularity at t=0 for y. So let's first rewrite ...

Coding a system of differential equations

Numerically solving the original system will make difficulties because of the singularity at t=0 for y. So let's first rewrite ...

17 days ago | 0

| accepted

Answered

Product of vector elements where the vector has a large size

Product_V = exp(sum(log(V(1,:)))/numel(V))

Product of vector elements where the vector has a large size

Product_V = exp(sum(log(V(1,:)))/numel(V))

17 days ago | 0

| accepted

Answered

The output of ode45 does not make much sense

function main n0 = 1.0; %assume value for n(0) epsilonmax0 = 10; %assume value for epsilonmax x0 = ...

The output of ode45 does not make much sense

function main n0 = 1.0; %assume value for n(0) epsilonmax0 = 10; %assume value for epsilonmax x0 = ...

19 days ago | 0

Answered

Runge kutta 4 probelm

function main g = 9.81; m = 71; k = 1000; l_0 = 8; tstart = 0.0; tend = 10.0; h = 0.01; T = (tstart:h:te...

Runge kutta 4 probelm

function main g = 9.81; m = 71; k = 1000; l_0 = 8; tstart = 0.0; tend = 10.0; h = 0.01; T = (tstart:h:te...

20 days ago | 1

Answered

One of the constant input variable need to be changed based on previous step's output in ODE, Can anyone kindly help?

Either you insert some delay elements (PT1 or similar) or you have to solve a delay differential equation (e.g. using dde23).

One of the constant input variable need to be changed based on previous step's output in ODE, Can anyone kindly help?

Either you insert some delay elements (PT1 or similar) or you have to solve a delay differential equation (e.g. using dde23).

20 days ago | 0

Answered

Given an equation and data points, find the best fit coefficients of the equation

x = 0:5; y = [1 3 9 27 81 243]; A = [ones(6,1),exp(x.')]; b = y.'; a = A\b; f = @(x) a(1)+a(2)*exp(x); plot(...

Given an equation and data points, find the best fit coefficients of the equation

x = 0:5; y = [1 3 9 27 81 243]; A = [ones(6,1),exp(x.')]; b = y.'; a = A\b; f = @(x) a(1)+a(2)*exp(x); plot(...

20 days ago | 0

| accepted

Answered

Why is ySol(t) = Dsolve(ode,cond) wrong? What should it be instead?

syms Cs t y(t) ode = diff(y,t) == 40*Cs-40/280*y; cond = y(0) == Cs; ySol(t) = dsolve(ode,cond); ysol_num = subst(ySol,Cs,C)...

Why is ySol(t) = Dsolve(ode,cond) wrong? What should it be instead?

syms Cs t y(t) ode = diff(y,t) == 40*Cs-40/280*y; cond = y(0) == Cs; ySol(t) = dsolve(ode,cond); ysol_num = subst(ySol,Cs,C)...

21 days ago | 1

Answered

Utilizing the Euler Method

In the if-statement in Flight.m, set x3 to x(3,i-1) and calculate the other variables x4,x5,f,u1,u2,u3,V_ver,C_D,Cl and p only f...

Utilizing the Euler Method

In the if-statement in Flight.m, set x3 to x(3,i-1) and calculate the other variables x4,x5,f,u1,u2,u3,V_ver,C_D,Cl and p only f...

21 days ago | 0

| accepted