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

Asif Rashid
Asif Rashid 2020년 7월 18일
z=reshape(zz,[5,4])
converts vector into a matrix as MATLAB needs z to be a matrix not a vector

댓글을 달려면 로그인하십시오.

 채택된 답변

madhan ravi
madhan ravi 2020년 7월 18일
편집: madhan ravi 2020년 7월 18일

0 개 추천

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

Asif Rashid
Asif Rashid 2020년 7월 18일
Sir, Thankyou for your Answer. I have tried implementing this but until command 4 , the code is running without errors but when i write 5th command that is mesh(x,y,z) amd run the program, i am encountered with the same error 'Data dimensions must agree'
command 1
x=reshape(PitchAngle,1,[]);
command 2
y=reshape(TipSpeedRatio,1,[]);
command 3
[xx,yy]=meshgrid(x,y);
command 4
z = repmat(PowerCoefficient(:), 1, size(xx, 2));
command 5
mesh(x,y,z)
on the workspace
x is shown ( value) as 1x20 double
xx is shown (value) as 1x20 double
y is shown (value) as 44250
yy is shown (value) as 1x20 double
z is shown (value) as 20x20 double
Please guide
mesh(xx, yy, z)
Asif Rashid
Asif Rashid 2020년 7월 18일
Thankyou Sir. It worked
Asif Rashid
Asif Rashid 2020년 7월 20일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

질문:

2020년 7월 18일

댓글:

2020년 7월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by