필터 지우기
필터 지우기

graph mesh code help

조회 수: 1 (최근 30일)
Chester710
Chester710 2022년 10월 20일
댓글: Chester710 2022년 10월 20일
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
Dyuman Joshi
Dyuman Joshi 2022년 10월 20일
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 2022년 10월 20일
Thanks for answering
then how can i write this ?

댓글을 달려면 로그인하십시오.

채택된 답변

David Hill
David Hill 2022년 10월 20일
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));
  댓글 수: 1
Chester710
Chester710 2022년 10월 20일
Thank you sir

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by