How can I match the dimension from two vectors?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm coding an app where the user provides data to a UItable and calculus must be made from that. When I enter values like 1,2,3..6 the code works but it launches this "warning: converting X to matrix of double". If I enter up other data it doesn't work because "Arrays have incompatible sizes for this operation." and "Error using curvefit.attention.Error/throw X must be a matrix with one or two columns." I used "format g" but I don't how to set a size for the array.
global tabla
tabla=app.UITable.Data;
h=cell2mat(tabla(:,1));
tP=cell2mat(tabla(:,2));
tT=cell2mat(tabla(:,3));
V=(pi*(dtr/2)^2.*h)/1000; %Volumen recolectado en funcion de la altura del tambor recolector (L)
Q1=V./tT; %Caudal en funcion de los tiempos por acumulado (L/s)
Q2=V./tP; %Caudal en funcion de los tiempos tomados de forma corrida (L/s)
[f1,R]=fit(tT,Q1,'poly1'); %Ajuste polinomico para ecuacion de la recta
Rcuadrado=num2str(R.rsquare); %Regresion lineal de la data obtenida
m1=f1.p1; b1=f1.p2; %donde p1 es pendiente y p2 es punto de corte
fit1=m1.*tT+b1
[f2,R]=fit(tP,Q2,'poly1');
Rcuadrado2=num2str(R.rsquare);
m2=f2.p1; b2=f2.p2;
fit2=m2.*tP+b2
3 Kommentare
Adam Danz
am 10 Mär. 2023
Assuming dtr is a 1x1 scalar, h, tP, and tT must be column vectors, otherwise you will get the error you see: X must be a matrix with one or two columns.
I'm curious why you need cell2mat when indexing from a table. It's a bit of a red flag.
Confirm that h, tP, and tT are column vectors and doubles using these lines
assert(isa(h,'double') && isvector(h) && size(h,2)==1, 'h is not a double vector')
assert(isa(tP,'double') && isvector(tP) && size(tP,2)==1, 'tP is not a double vector')
assert(isa(tT,'double') && isvector(tT) && size(tT,2)==1, 'tT is not a double vector')
Antworten (0)
Siehe auch
Kategorien
Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!