>> t=linspace(0,2,100);
>> x=t; y=t. ^2; z=t.^3;
>> plot3 (x,y,z), grid
>> t=linspace(–5,5,50); y=x;
>> z=–7./(1+x.^2+y.^2);
>> mesh(z)

댓글 수: 3

Daniel Pollard
Daniel Pollard 2021년 4월 14일
Well z isn't a matrix, it's a vector, with the same dimensions as t, which is why it gave that error. What were you trying to do?
@Daniel Pollard What corrections should I make ?
Daniel Pollard
Daniel Pollard 2021년 4월 15일
I don't know how to answer that when I don't know what the aim of your code is. Star Strider has left an answer - perhaps they figured out what you're after?

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

답변 (1개)

Star Strider
Star Strider 2021년 4월 14일

1 개 추천

The arguments to ‘z’ need to be matrices in order for ‘z’ to be a matrix. Use ndgrid or meshgrid (linked to on that page) to create the matrices.
Try this:
t=linspace(0,2,100);
x=t;
y=t.^2;
z=t.^3;
figure
plot3(x,y,z)
grid on
t=linspace(-5,5,50);
y=x;
[X,Y] = ndgrid(x,y);
z= @(x,y) -7./(1+x.^2+y.^2);
figure
mesh(X,Y,z(X,Y))
.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2021년 4월 14일

댓글:

2021년 4월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by