how i plot this function

10 vues (au cours des 30 derniers jours)
muhammad asif
muhammad asif le 30 Sep 2020
Commenté : Star Strider le 30 Sep 2020
u(x,t)=t+sin(x-a*t)

Réponse acceptée

Star Strider
Star Strider le 30 Sep 2020
One way, using the exact equation you posted:
syms x t
a = 4.2; % Use Appropriate Value
u(x,t) = t+sin(x-a*t);
figure
fsurf(u, [- pi pi 0 1])
and another possibility:
x = linspace( ... ); % Create Vector
t = linspace( ... ); % Create Vector
[X,T] = ndgrid(x,t);
u = @(x,t) t+sin(x-a.*t);
figure
mesh(X, T, u(X,T))
grid on
.
  2 commentaires
muhammad asif
muhammad asif le 30 Sep 2020
group should be like that sir.
Star Strider
Star Strider le 30 Sep 2020
There appears to be missing data. I cannot guess what they are.
Try this:
x = linspace(-2*pi, 2*pi, 25); % Create Vector
t = linspace(-2*pi, 2*pi, 25); % Create Vector
a = 1;
[X,T] = ndgrid(x,t);
u = @(x,t) t+sin(x-a.*t);
figure
plot(t, u(X,T))
hold on
plot(t, x, 'k', 'LineWidth',2)
hold off
grid on
That is as close as I can get.
Experiment with the code to get the result you want.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by