I have a problems to graph in 3D
Info
This question is closed. Reopen it to edit or answer.
Show older comments
when i run it tells me that "vectors must be the same length" and "error (line7) plot3(x,y,z)"
clc
clear all
x=-20:0.01:30;
y=-20:0.01:30;
%Ecuacion
z=sin(sqrt(x.^2+y.^2))/sqrt(x.^2+y.^2+0.2);
plot3(x,y,z)
[A,B]=meshgrid(-30:0.1:20);
Z=sin(sqrt((A.^2)+(B.^2)))/sqrt(A.^2+B.^2+0.2);
figure
mesh(A,B,Z)
Answers (1)
Star Strider
on 6 May 2020
‘vectors must be the same length’
Yes, they must.
If you remember to use element-wise division:
z=sin(sqrt(x.^2+y.^2))./sqrt(x.^2+y.^2+0.2);
↑ ← HERE
they are, and the first figure plots correctly.
Remember to do that in the second one as well:
Z=sin(sqrt((A.^2)+(B.^2)))./sqrt(A.^2+B.^2+0.2);
↑
and that figure plots correctly as well.
2 Comments
Jesus Andrik Evangelista Tomatzin
on 7 May 2020
Star Strider
on 7 May 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!