Unable to sove for all parameters

2 ビュー (過去 30 日間)
Chitransh Singh
Chitransh Singh 2019 年 4 月 16 日
コメント済み: Torsten 2019 年 4 月 16 日
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.

回答 (1 件)

Kevin Chng
Kevin Chng 2019 年 4 月 16 日
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 件のコメント
Torsten
Torsten 2019 年 4 月 16 日
Or use "ndgrid":
https://de.mathworks.com/help/matlab/ref/ndgrid.html

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by