error using horz cat in app desiner
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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)
0 commentaires
Réponses (1)
Simon Chan
le 25 Mar 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
0 commentaires
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!