Calculating values of a dependent variable at a using a range of independent variables

조회 수: 13 (최근 30일)
Hi,
I'm new to matlab so this might be very simple but....
I have this equation;
Eff=((Cv.*Temp.*(1-Vr))+(((2.*l.*S.*S)./(n.*n))*((Vi./(pi.*Rb.*Rb))-l))+(M./(R.*Temp))+((Vr^(1-k)).*(R.*Temp./M)))/((Cv.*Temp)+((R.*Temp)./M)+(((S.*Vi)./(sqrt(2).*n.*pi.*Rb.*Rb))^2))
All of the variables are constants except Eff and Temp. I would like to calculate values of Eff using Temp between a range of 373 and 623 so that I can plot a graph to investigate the effect of Temp on Eff.
Any Advice would be greatly appreciated

채택된 답변

Chad Greene
Chad Greene 2021년 3월 10일
Welcome to the world of Matlab, Tom.
Indeed, I think this is pretty straightforward. To make a range of values of Temp between 373 and 623, do
Temp = 373:623;
Alternatively, to do the same thing but in steps of 0.1, do
Temp = 373:0.1:623;
Then calculate Eff by
Eff=((Cv.*Temp.*(1-Vr))+(((2.*l.*S.*S)./(n.*n))*((Vi./(pi.*Rb.*Rb))-l))+(M./(R.*Temp))+((Vr^(1-k)).*(R.*Temp./M)))/((Cv.*Temp)+((R.*Temp)./M)+(((S.*Vi)./(sqrt(2).*n.*pi.*Rb.*Rb))^2));
and plot the results like this:
plot(Temp,Eff)
  댓글 수: 4
Chad Greene
Chad Greene 2021년 3월 10일
Ahh, try this. It looks like a few dot operators were missing. My go-to solution when things are acting funny with multiplication, division, or exponents, is to put a dot in front of each one. That seems to have fixed it.
Eff=((Cv.*Temp.*(1-Vr))+(((2.*l.*S.*S)./(n.*n)).*((Vi./(pi.*Rb.*Rb))-l))+(M./(R.*Temp))+((Vr.^(1-k)).*(R.*Temp./M)))./((Cv.*Temp)+((R.*Temp)./M)+(((S.*Vi)./(sqrt(2).*n.*pi.*Rb.*Rb)).^2));
Tom Morris
Tom Morris 2021년 3월 10일
That's got it! Thank you so much for your help, I was going a bit crazy there.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by