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!