error using horz cat in app desiner

1 visualización (últimos 30 días)
Abdulrahman Mohamed
Abdulrahman Mohamed el 25 de Mzo. de 2022
Respondida: Simon Chan el 25 de Mzo. de 2022
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)

Respuestas (1)

Simon Chan
Simon Chan el 25 de Mzo. de 2022
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

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by