Defining a piecewise function of two variables

I need to plot the solution of a wave equation in three dimension. The solution is in this form: u(x,t)= sin(xt) if x>t; 0 if x<=t. The problem is I am not able to define such function of two variables. While searching I got the way to define functions using the command "piecewise" but it is not working in my case. More precisely, I tried the following code:
x=linspace(0,1,50);
t=linspace(0,1,50);
[x,t]=meshgrid(x,t);
z= piecewise(x>t, sin(x*t), x<=t, 0)
mesh(z,x,t)
Please advice.

回答 (0 件)

カテゴリ

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

質問済み:

2017 年 3 月 30 日

編集済み:

2017 年 3 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by