How do I fix my meshgrid?
Ältere Kommentare anzeigen
This is the code i have inserted and im getting this. Where is the mistake in my coding and how do I fix this?
gridspacing=-8:0.5:8;
Y=-8:0:8;
Z=-8:1.5:8;
[x,Y] = meshgrid (-8:0.5:8);
Z=sqrt(exp(-x.^2-Y.^2))
surf(x,Y,Z,x.*exp(Y))
Z(R==0)=1
z = sin (R)/R
4 Kommentare
Shubham Gupta
am 24 Okt. 2019
What result were you expecting? Why are you defining gridspacing, Y & Z even though you are redefing Y & Z and not using gridspacing? You have not defined R?
Briana Pass
am 24 Okt. 2019
Katie
am 24 Okt. 2019
In your Y vector, your step size is 0 so it's an empty vector. Are you trying to pre-allocate the memory for the Y matrix that is generated by the meshgrid function? If so, you can use the following:
Y=zeros(length(gridspacing),length(gridspacing));
However, this will not change the plotted result. If you could provide some more info about what you're expecting to see, that would be great!
Briana Pass
am 24 Okt. 2019
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Red finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

