필터 지우기
필터 지우기

how do i plot the following in 3D

조회 수: 1 (최근 30일)
Tlotlo Oepeng
Tlotlo Oepeng 2021년 5월 28일
답변: Walter Roberson 2021년 5월 29일
i have x and y which are matrices
i perform operations to get U which is a coulmn vector how do i plot it agaisnt x,y which are matices. the erro i get is that z must be a matrix not scalor or vector
x=-(ngrid/2:ngrid/2-1)*0.2
[X,Y] = meshgrid(x,x)
u%outputs coulmn vectors
my output U from my workspace is a coulu vector of 1x2001
  댓글 수: 7
Walter Roberson
Walter Roberson 2021년 5월 28일
U = exp(-0.5.*x.^2-0.5.*y.^2-0.5.*t.^2);
You need to rewrite U in terms of X and Y instead of x and y . But X and Y are 2D and probably not the same size as t, so you would need to reshape t into the third dimension, or
[X, Y, T] = meshgrid(x, x, t);
U = exp(-0.5.*X.^2-0.5.*Y.^2-0.5.*T.^2);
But now U will be 3D and you need to summarize it down to 2D in order to use a surface plot.
k1 = fU( z(i) , U(i) ); % first slope
That whole section would need to be rewritten in terms of U being 3D.
Tlotlo Oepeng
Tlotlo Oepeng 2021년 5월 29일
thank you ill try to di that
how do i accept answer?

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

채택된 답변

Walter Roberson
Walter Roberson 2021년 5월 29일
[Copied from comment]
U = exp(-0.5.*x.^2-0.5.*y.^2-0.5.*t.^2);
You need to rewrite U in terms of X and Y instead of x and y . But X and Y are 2D and probably not the same size as t, so you would need to reshape t into the third dimension, or
[X, Y, T] = meshgrid(x, x, t);
U = exp(-0.5.*X.^2-0.5.*Y.^2-0.5.*T.^2);
But now U will be 3D and you need to summarize it down to 2D in order to use a surface plot.
k1 = fU( z(i) , U(i) ); % first slope
That whole section would need to be rewritten in terms of U being 3D.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by