# I want to plot from -5 to 5 on the x and y, but I am having trouble. Any help?

1 view (last 30 days)
Luis Hernandez on 17 Feb 2020
Edited: Khalid Mahmood on 14 Apr 2021
I want to plot from -5 to 5 on both the x andy
%mesh
X=-5:.5:5;
Y=-5:.5:5;
[x y]=meshgrid(X,Y);
% calculate
f=exp(-0.25.*sqrt(x.^2+y.^2));
%imagesc
figure(1)
imagesc(f);
colorbar
xlabel('x');
ylabel('y');
title('imagesc with colorbar')
figure(2)
quiver(fx,fy)
xlabel('fx');
ylabel('fy');
Khalid Mahmood on 14 Apr 2021
Hope you need this:

Srivardhan Gadila on 20 Feb 2020
Use the imagesc and quiver as follows:
imagesc(X,Y,f);
quiver(x,y,fx,fy);

Khalid Mahmood on 14 Apr 2021
Edited: Khalid Mahmood on 14 Apr 2021
%Hope you need this. I mean just plot mesh also
%mesh
Lim=-5:.5:5; %both x,y have same limits
[x y]=meshgrid(Lim);
% calculate
f=exp(-0.25.*sqrt(x.^2+y.^2));
%imagesc
figure(1)
subplot(211);imagesc(f); subplot(212);mesh(x,y,f)
colorbar
xlabel('x');
ylabel('y');
title('imagesc with colorbar')
figure(2)
surf(x,y,fx,fy)%quiver(fx,fy)
xlabel('fx');
ylabel('fy');