How to do a loop to evaluate a function with a varying value?
古いコメントを表示
Hi there! Studying crack propagation in Comsol, I got to a result that is a function that consists of 4 parameters: Chi, Omega, Lambda0 and CS. The equation is:
J = (Cs.*Omega.*lambda0.^8-Cs.*Omega.*lambda0.^5-2.*chi.*lambda0.^3+lambda0.^3+2.*chi).^2/(2.*chi.*lambda0.^3-lambda0.^3-2.*chi).^2;
How do I evaluate the influence of each parameter on the final value? To me, I could fix 3 parameters and vary the remaining one (the simplest case). But, Is there any how to make this analisys in a different way?
I tried a loop for the simplest case, but it doesn't work:
for i=1:100
chi=1:01:1;
Omega=4;
Cs=2;
lambda0=5;
x(i)=(Cs.*Omega.*lambda0.^8-Cs.*Omega.*lambda0.^5-2.*chi.*lambda0.^3+lambda0.^3+2.*chi).^2/(2.*chi.*lambda0.^3-lambda0.^3-2.*chi).^2;
end
plot(chi,x)
Shame on me, guys! LOL I am terrible at MATLAB.
Can anyone help me, please?
回答 (1 件)
Torsten
2018 年 1 月 23 日
chi=0:0.01:1;
Omega=4;
Cs=2;
lambda0=5;
x=(the expression from above);
plot(chi,x)
Best wishes
Torsten.
3 件のコメント
InWend
2018 年 1 月 23 日
Torsten
2018 年 1 月 23 日
x will be a vector of the same size as chi.
Best wishes
Torsten.
Star Strider
2018 年 1 月 23 日
You need to define ‘chi’ correctly:
chi=1:01:1;
chi =
1
カテゴリ
ヘルプ センター および File Exchange で Functional Programming についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!