Error: Illegal use of reserved keyword "end".

조회 수: 5 (최근 30일)
UDIT
UDIT 2023년 8월 19일
댓글: Dyuman Joshi 2023년 8월 19일
m=input('Enter the mass of water in kg -');
Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering.
cpw=4.187;%Cp of water is taken as 4.187 KJ/kg K
T1=input('Enter the inital temperature of water in kelvin :- '); %water initial temperature
Tinter1=input('Enter the intermediate temperature of water in kelvin :- ');; %first reservoir temperature
T2=input('Enter the final temperature of water in kelvin :- ');
for(m=1:5:30)
Q1=m*cpw*(Tinter1-T1);
Q2=m*cpw*(T2-Tinter1);
deltaSwater= m*cpw*[log(Tinter1/T1)+log(T2/Tinter1)];
deltaSreservoir1=-Q1/(Tinter1);
deltaSreservoir2=-Q2/(T2);
deltaSUniverse=deltaSwater+deltaSreservoir1+deltaSreservoir2;
disp('Analysis for TER and system')
fprintf('Heat transferred from TER1 to water is:- %f kJ \n',Q1)
fprintf('Heat transferred from TER2 to water is:- %f kJ \n',Q2)
fprintf('deltaSwater=%f kJ/K \n',deltaSwater)
fprintf('deltaSreservoir1= %f kJ/K\n',deltaSreservoir1)
fprintf('deltaSreservoir2= %f kJ/K\n',deltaSreservoir2)
fprintf('deltaSUniverse= %f kJ/K\n',deltaSUniverse)
end
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 8월 19일
In which line does the error occur?
Please copy and paste the whole error message i.e. all of the red text.

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

답변 (1개)

KSSV
KSSV 2023년 8월 19일
Remove end in the code which is lying in the last.
  댓글 수: 3
Torsten
Torsten 2023년 8월 19일
The "end" is the closing "end" of the for-loop.
Walter Roberson
Walter Roberson 2023년 8월 19일
@Torsten is correct, at least when the code is formatted the way it looks like it should be.
When I format the code and execute it, I do not get any message about the end

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

카테고리

Help CenterFile Exchange에서 Dynamic System Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by