필터 지우기
필터 지우기

error in unrecognized variable or function?

조회 수: 1 (최근 30일)
Abdulrahman Mohamed
Abdulrahman Mohamed 2022년 3월 25일
댓글: Sam Chak 2022년 3월 25일
I want to make calculation at different x values that yeilds r then plotted and put in table in app designer but the problem that there is error that unrecognized variable or function "r''
here is the code
value = app.minPEditField.Value;
Rs=app.RsSCFSTBEditField.Value;
T=app.TREditField.Value;
API=app.APIEditField.Value;
Pb=app.PbEditField.Value;
P=app.CurrentPressureEditField.Value;
min=app.minPEditField.Value;
max=app.MaxPEditField.Value;
uodead=app.uodcpEditField.Value;
uob=app.uobcpEditField.Value;
for xn=14.7:100:max
switch app.SelectCorrelationDropDown_3.Value
case 'The VASQUEZ-Beggs'
a=-3.9*(10^-5)*(P)-5;
m=2.6*(P^1.187)*(10^a);
uob=app.uobcpEditField.Value;
r=uob*(P/Pb)^m;
case 'Debogh'
x=2.6*(P^1.187)*exp(-11.513-8.98*10^-5*(P))
uob=app.uobcpEditField.Value;
r=uob*(P/Pb)^x;
otherwise
disp("please select correlation")
end
end
v=transpose(xn);
y=transpose(r);
m=[v y];
app.UITable.Data=m;
plot(app.UIAxes,v,y)

답변 (1개)

Walter Roberson
Walter Roberson 2022년 3월 25일
1) Your code does not define r for the case where the switch() does not match either case;
2) Your code is not producing one r value per xn value. At the end of the loop, you are going to have a scalar in r (if you have anything)
3) Your results do not depend upon xn at all
4) After a for loop, the loop control variable is left with the last value it was assigned, which would be a scalar in this case. Your context suggest that you are expecting a vector.
  댓글 수: 2
Abdulrahman Mohamed
Abdulrahman Mohamed 2022년 3월 25일
so what is the solution for that
Sam Chak
Sam Chak 2022년 3월 25일
Rather than directly demanding a solution in a blunt manner, it is polite to request for an explanation for each of the comments, so that you get the idea of how to proceed, and rework your code, if you are interested to learn and gain some knowledge or skills from the experience.
If you are interested merely on the solution, you could hire a professional to help, to achieve more in less time.

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by