Unable to sove for all parameters
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Kevin Chng
le 16 Avr 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 commentaire
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!