Error in displaying 3Dmesh in a for loop

i want to make a single program for displaying the numerical solution of u(x, t) and also showing the space time graph i.e. mesh (x, t, u).
clc; clear all
q = 1.5;
k = 0.1;
for t =[0.01:0.01:0.1], x = [-1, -0.655, 0, 0.655, 1];
u =((q -2*(k.^2))/3)+ 2*(k.^2)*tanh(k*(x + q*t)).^2;
end
figure(1)
[X,T] = meshgrid(x,t);
mesh(x,t,u);
grid on;
xlabel('x','fontsize',16);
ylabel('t','fontsize',16);
zlabel('u','fontsize',16);
box on;
title('Space-time graph of numerical solution u','fontsize',16');
i'm getting error kindly suggest what should i do?

1 件のコメント

R shah
R shah 2016 年 8 月 5 日
i've solved it without using for loop as;
clc; clear all
q = 1.5;
k = 0.1;
[x,t] = meshgrid([-1, -0.655, 0, 0.655, 1], 0.1:0.2:2);
u =((q -2*(k.^2))/3)+ 2*(k.^2)*tanh(k*(x + q*t)).^2;
figure(1)
[X,T] = meshgrid(x,t);
mesh(x,t,u);
grid on;
xlabel('x','fontsize',16);
ylabel('t','fontsize',16);
zlabel('u','fontsize',16);
box on;
title('Space-time graph of numerical solution u','fontsize',16');

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2016 年 8 月 3 日

コメント済み:

2016 年 8 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by