basics about surface plot
Show older comments
Hi, I'm trying to do the "2d advection equation" and I'm stuck with the way you need to plot surface. I apologize in advance for possible unclear things in my question because I don't really know how to put it in words.
But even before that.
Mathematically you start with C0=[C(x) ; C(y)]. (In my case C(x) and C(y) are vector made with a gauss equation thus making C0 a matrix 2xN)
I've understood that the first step is to create a grid with meshgrid in order to tell the program the range of x and y axis.
Then I don't know. The idea is to represent to concentration like that. So far my code looks like this:
clear, clc, clf
#Gauss curve equation
dx=0.1; #step size x
dy=0.5; #step size y
Lx=-5:0.1:5; #range of domain x
Ly=-5:0.1:5; #range of domain y
dt=dx.^2/2.5; #time step size
Gx=exp(-Lx.^2); #initial concentration x based on gauss curve
Gy=exp(-Ly.^2); #initial concentration y based on gauss curve
#variable
V1=1; #velocity1
V2=2; #velocity2
#Advection in 2D
Cx=Gx;
Cy=Gy;
C=[Cx ; Cy];
[X Y]=meshgrid(Lx,Ly);
contour(X,Y,C)
I read the different information about function like contour, mesh, griddata but they are a bit rough for me and they don't help me to understand how matlab thinks .
Thank you in advance for your help.
Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!