MATLAB Answers

I would like to change the massflowrate when the statement is correct, could you help?

1 ビュー (過去 30 日間)
Adam Street
Adam Street 2020 年 3 月 14 日
コメント済み: Adam Street 2020 年 3 月 14 日
For some reason the massflowrate doesn't change itself whenever I enter the following, no errors or anything appear. Just got no clue how to fix this.
electricalsignal=5;
massflowrate=3;
if electricalsignal==0
disp("error")
else
temperature = 200*electricalsignal-400;
end
if temperature<74;
disp("opening valves")&& massflowrate == massflowrate-50;
elseif (74<=temperature) && (temperature>=78)
disp("closing valves")
elseif temperature>78
disp("closing valves") && massflowrate == massflowrate+50;
endif
  1 件のコメント
Guillaume
Guillaume 2020 年 3 月 14 日
I would strongly recommend that you go through the free matlab onramp to learn the basics of matlab.
I'm not entirely sure what you're trying to achieve with these lines:
disp("opening valves")&& massflowrate == massflowrate-50;
it's a completely made up syntax.

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

採用された回答

Subhamoy Saha
Subhamoy Saha 2020 年 3 月 14 日
編集済み: Subhamoy Saha 2020 年 3 月 14 日
The problem is with the line you are changing values of massflowrate. You are making it logical condition rather assigning it a new value. Please try the following
electricalsignal=5;
massflowrate=3;
if electricalsignal==0
disp("error")
else
temperature = 200*electricalsignal-400;
end
if temperature<74;
disp("opening valves"), massflowrate = massflowrate-50; % corrected
elseif (74<=temperature) && (temperature>=78)
disp("closing valves")
elseif temperature>78
disp("closing valves"), massflowrate = massflowrate+50; % corrected
end
  5 件のコメント
Adam Street
Adam Street 2020 年 3 月 14 日
Subhamoy Saha,
Thank you very much!!!

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by