Surface plot function with two variable
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Matteo Tagliabue
le 12 Avr 2022
Modifié(e) : Davide Masiello
le 12 Avr 2022
Hello, I am trying to reproduce the graph of the surface as shown in the image but I get only 'oscillation on one axis while the other remains constant. Does anyone have any advice?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/961790/image.png)
Here my code
f= 0.5;
c = 3*10^8;
lambda = c/f
phi = 0
K = 2*pi/lambda
omega = 2*pi*f
E_0=1;
t = linspace(0,5,1000);
x =linspace(0,5,1000)';
E = E_0.*sin(K*x-omega*t);
E = rot90(E);
[X,Y] = meshgrid(1:length(E),1:length(E));
surf(X,Y,E,'EdgeColor','interp')
xlabel('X axis')
ylabel('time axis')
0 commentaires
Réponse acceptée
Davide Masiello
le 12 Avr 2022
Modifié(e) : Davide Masiello
le 12 Avr 2022
Your x and t spans are not convenient. Try this
f = 0.5;
tau = 1/f;
c = 3*10^8;
lambda = c/f;
phi = 0;
K = 2*pi/lambda;
omega = 2*pi*f;
E_0 = 1;
t = linspace(0,tau*3,1000);
x = linspace(0,lambda*3,1000);
[T,X] = meshgrid(t,x);
E = E_0*sin(K*X-omega*T);
surf(T,X,E,'EdgeColor','interp')
xlabel('Time axis')
ylabel('x axis')
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!