Unable to sove for all parameters

1 Ansicht (letzte 30 Tage)
Chitransh Singh
Chitransh Singh am 16 Apr. 2019
Kommentiert: Torsten am 16 Apr. 2019
i have an equation with a number of variables and i need to calculate the velocity. the equation is-
v=[((ta*xp)+(tb*xn))*(w/(2*pi))]
where ta, xp, tb, xn and w all vary within a certain limit. I cannot do matrix calculation due to unequal matrix dimensions.. I am applying the for loop to get the results forr each value of each parameter. But what i am getting in the workspace is a 1*1 matrix.
The code i am using is-
clc
clear all
for ta=linspace(0.017,0.349,20)
for xp=linspace(0,20,20)
for tb=linspace(0.017,0.349,20)
for xn=linspace(0,20,20)
for w=linspace(1.67,18.33,11)
v=[((ta*xp)+(tb*xn))*(w/(2*pi))]
end
end
end
end
end
Plz help me to solve this equation to get different values of v for each value of all the variables. Also help me on how to plot a graph with w on x axis and rest all parameters on y-axis from the solution of this equation
I guess i need to get 20*20*20*20*11=1760000 values for this equation.

Antworten (1)

Kevin Chng
Kevin Chng am 16 Apr. 2019
clc
clear all
i=1;
summary=table;
for ta=linspace(0.017,0.349,20)
for xp=linspace(0,20,20)
for tb=linspace(0.017,0.349,20)
for xn=linspace(0,20,20)
for w=linspace(1.67,18.33,11)
summary.w(i)=w;
summary.v(i)=[((ta*xp)+(tb*xn))*(w/(2*pi))];
summary.ta(i)=ta;
summary.xp(i)=xp;
summary.tb(i)=tb;
summary.xn(i)=xn;
i=i+1
end
end
end
end
end
plot(summary.w,summary.v,'ro')
hold on
plot(summary.w,summary.ta,'bo')
plot(summary.w,summary.xp,'go')
plot(summary.w,summary.tb,'co')
plot(summary.w,summary.xn,'yo')
legend('v','ta','xp','tb','xn')
Now your 1x1760000 double data is save in v. Plot them with 0 marker.
  1 Kommentar
Torsten
Torsten am 16 Apr. 2019
Or use "ndgrid":
https://de.mathworks.com/help/matlab/ref/ndgrid.html

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by