필터 지우기
필터 지우기

error using horz cat in app desiner

조회 수: 1 (최근 30일)
Abdulrahman Mohamed
Abdulrahman Mohamed 2022년 3월 25일
답변: Simon Chan 2022년 3월 25일
I am trying to make calculation at different range of x based on user input for minimum and maximum also, i added specific calculation y for each x input then i want to put in table and plot in the graph in App desiner but i got error "error using horz cat in app desiner'
Herer is the code
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;
dead=app.uodcpEditField.Value;
uob=app.uobcpEditField.Value;
x=min:100:max;
xn=transpose(x);
if xn==14.7
y=dead;
elseif xn==Pb
y=uob;
elseif xn>Pb
a=-3.9.*(10^-5).*(xn)-5;
m=2.6*(xn.^1.187).*(10.^a);
uob=app.uobcpEditField.Value;
y=uob.*(xn/Pb).^m;
else
y=uob;
end
m=[xn y];
app.UITable.Data=m;
plot(app.UIAxes,xn,y)

답변 (1개)

Simon Chan
Simon Chan 2022년 3월 25일
Variable x is from min:100:max and hence it should not be a single number.
However, varibale y in your code seems to be a single number and hence it gives an error when you use function horzcat.
Adding an index to both variable xn and y as shown below should fix the problem.
x=min:100:max;
xn=transpose(x);
for k = 1:length(x)
if xn(k)==14.7
y(k,1)=dead;
elseif xn(k)==Pb
y(k,1)=uob;
elseif xn(k)>Pb
a=-3.9.*(10^-5).*(xn(k))-5;
m=2.6*(xn(k).^1.187).*(10.^a);
uob=111;
y(k,1)=uob.*(xn(k)/Pb).^m;
else
y(k,1)=uob;
end
end

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by