Borrar filtros
Borrar filtros

graph mesh code help

1 visualización (últimos 30 días)
Chester710
Chester710 el 20 de Oct. de 2022
Comentada: Chester710 el 20 de Oct. de 2022
hey i'm trying to graph this code but i get error "Z must be a matrix, not a scalar or vector."
syms x
a=1-(exp(-x/sqrt(2))/2+exp(-x/sqrt(2)));
b=exp(-x/sqrt(2))/((2+exp(-x/sqrt(2)))^2);
c=((exp(-x/sqrt(2))*(exp(-x/sqrt(2))-2)))/4*((2+exp(-x/sqrt(2)))^3);
d=(exp(-x/sqrt(2))*(((exp(-x/sqrt(2)))^2)-8*(exp(-x/sqrt(2)))+4))/24*((2+exp(-x/sqrt(2)))^4);
syms t
[X,Y]=meshgrid(-1:1.-1:1)
Z=a+(t*b)+(c*t^2)+(d*t^3)
mesh(X,Y,Z)
  2 comentarios
Dyuman Joshi
Dyuman Joshi el 20 de Oct. de 2022
The increment value seems to be incorrect or a typo
[X,Y]=meshgrid(-1:1.-1:1)
Also, for using mesh(), it is necessary for the 3rd input or Z, to be a matrix.
Chester710
Chester710 el 20 de Oct. de 2022
Thanks for answering
then how can i write this ?

Iniciar sesión para comentar.

Respuesta aceptada

David Hill
David Hill el 20 de Oct. de 2022
a=@(x)1-exp(-x/sqrt(2))./(2+exp(-x/sqrt(2)));
b=@(x)exp(-x/sqrt(2))./((2+exp(-x/sqrt(2))).^2);
c=@(x)((exp(-x/sqrt(2)).*(exp(-x/sqrt(2))-2)))./(4*((2+exp(-x/sqrt(2))).^3));
d=@(x)(exp(-x/sqrt(2)).*(((exp(-x/sqrt(2))).^2)-8*(exp(-x/sqrt(2)))+4))./(24*((2+exp(-x/sqrt(2))).^4));
Z=@(x,t)a(x)+t.*b(x)+c(x).*t.^2+d(x).*t.^3;
[x,t]=meshgrid(-1:.01:1);
mesh(x,t,Z(x,t));

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by