How can I match the dimension from two vectors?

5 visualizzazioni (ultimi 30 giorni)
Giulia Di Giorgio
Giulia Di Giorgio il 10 Mar 2023
Commentato: Adam Danz il 10 Mar 2023
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
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
m2=f2.p1; b2=f2.p2;
  3 Commenti
Giulia Di Giorgio
Giulia Di Giorgio il 10 Mar 2023
of course, I want to try with this data:
on the "h"column: 10.00 , 20.00, 30.00, 40.00
on the "Tiempos P. (s)" column=51.91 54.58 59.58 61.80
on the "Tiempos T. (s)" column=51.91 106.49 166.07 227.87
I'll attatch a screenshot so you can see how the table looks like
Adam Danz
Adam Danz il 10 Mar 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')

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by