Data dimensions must agree

14 Ansichten (letzte 30 Tage)
Asif Rashid
Asif Rashid am 18 Jul. 2020
Kommentiert: Asif Rashid am 20 Jul. 2020
i have a function z which has two variables x and y. z , x and y are vectors of length 20. While plotting a function, MATLAB says that 'Data dimensions must agree'. Using the commands
x=PitchAngle;
y=TipSpeedRatio;
[xx,yy]=meshgrid(x,y);
zz=PowerCoefficient;
z=reshape(zz,[5,4])
mesh(x,y,z)
I dont know whether i am using the right command. Please lead me to the right way. Thankyou
  1 Kommentar
Asif Rashid
Asif Rashid am 18 Jul. 2020
z=reshape(zz,[5,4])
converts vector into a matrix as MATLAB needs z to be a matrix not a vector

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

madhan ravi
madhan ravi am 18 Jul. 2020
Bearbeitet: madhan ravi am 18 Jul. 2020
x = reshape(x, 1, []);
y = reshape(y, 1, []);
[xx, yy]=meshgrid(x,y);
z = repmat(zz(:), 1, size(xx, 2));
mesh(xx, yy, z)
  4 Kommentare
Asif Rashid
Asif Rashid am 18 Jul. 2020
Thankyou Sir. It worked
Asif Rashid
Asif Rashid am 20 Jul. 2020
Sir i i want to change the axis so when i wrote this code
x=reshape(TipSpeedRatio,1,[]);
y=reshape(PitchAngle,1,[]);
[xx,yy]=meshgrid(x,y);
z = repmat(PowerCoefficient(:), 1, size(xx, 2));
mesh(xx,yy,z)
I cant plot the figure successfully. untill command
z = repmat(PowerCoefficient(:), 1, size(xx, 2));
the code is running successfully but when i write
mesh(xx,yy,z)
i see the error that
Z must be a matrix, not a scalar or vector.
how may i fix this error. please guide

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Operating on Diagonal Matrices 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!

Translated by