Keep getting Matrix dimensions must agree warning

1 回表示 (過去 30 日間)
JK
JK 2015 年 11 月 5 日
回答済み: Star Strider 2015 年 11 月 5 日
I am attempting to plot the Gas Turbine efficiency as a function of the temperature ratio:
Tr=1:10<3;
n=1-1/Tr;
figure
plot(Tr,n)
When attempting to plot i get the following error:
Error in ==> test at 5
n=1.-1/Tr;
??? Error using ==> mrdivide
Matrix dimensions must agree.
Any help would be appreciated, thanks in advance.

回答 (2 件)

TastyPastry
TastyPastry 2015 年 11 月 5 日
You need to use element by element division, which is "./".

Star Strider
Star Strider 2015 年 11 月 5 日
I do not know what you intend with this assignment:
Tr=1:10<3;
since it creates this logical array:
Tr =
1 1 0 0 0 0 0 0 0 0
Which is likely not what you want, because it creates with this assignment:
n=1-1./Tr;
this result for ‘n’:
n =
0 0 -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf

カテゴリ

Help Center および File ExchangeGas Models についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by