Filter löschen
Filter löschen

graph mesh code help

1 Ansicht (letzte 30 Tage)
Chester710
Chester710 am 20 Okt. 2022
Kommentiert: Chester710 am 20 Okt. 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 Kommentare
Dyuman Joshi
Dyuman Joshi am 20 Okt. 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 am 20 Okt. 2022
Thanks for answering
then how can i write this ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

David Hill
David Hill am 20 Okt. 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));

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by