error using horz cat in app desiner

2 ビュー (過去 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 Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by