How to evaluate function with two variables

How to evaluate the function when f(x,y)=sin(pi*x)*exp(-(pi)^2*t) when t=0:0.1:0.5,x=0.2:0.2:0.8

 Respuesta aceptada

Stephen23
Stephen23 el 3 de Oct. de 2019
>> t = 0:0.1:0.5
t =
0.00000 0.10000 0.20000 0.30000 0.40000 0.50000
>> x = (0.2:0.2:0.8).'
x =
0.20000
0.40000
0.60000
0.80000
>> M = bsxfun(@times,sin(pi*x),exp(-(pi)^2*t))
M =
0.5877853 0.2190722 0.0816499 0.0304316 0.0113421 0.0042273
0.9510565 0.3544662 0.1321123 0.0492393 0.0183519 0.0068399
0.9510565 0.3544662 0.1321123 0.0492393 0.0183519 0.0068399
0.5877853 0.2190722 0.0816499 0.0304316 0.0113421 0.0042273

4 comentarios

qudsia Bashir
qudsia Bashir el 4 de Oct. de 2019
Thank you. Can you please also tell me how to plot this i used
plot(x,t,M)
but itsnot working
Stephen23
Stephen23 el 4 de Oct. de 2019
"Can you please also tell me how to plot this..."
Sure, how do you want to plot it:
  1. six lines with independent variable x
  2. four lines with independent variable t
  3. a surface or mesh or similar,
  4. something else...
qudsia Bashir
qudsia Bashir el 4 de Oct. de 2019
a surface or mesh
surf(t,x,M)
mesh(t,x,M)

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 3 de Oct. de 2019

Comentada:

el 4 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by