error in unrecognized variable or function?
조회 수: 2 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
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
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 Center 및 File Exchange에서 Downloads에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!