Surf 3D Matrix size issue

2 次查看(过去 30 天)
Hello everyone,
currently i try to understand some code i got from my supervisor in college. My task is to create a 3D plot. I've got vector V.x with dimension 1x41 and a vector V.y with dimension 1x41 as well. Besides that i got a 3D Matrix E with the dimension 41x41x301.
I tried to use surf(V.x,V.y,E).
I get an error because of the dimensions must agree.
Where is the Problem? Is it because of the "x301", because E is a 3D Matrix?
If so, how can i fix it?
Sincerely
Lucas

采纳的回答

Ameer Hamza
Ameer Hamza 2020-5-4
Yes, It is because of 3D array. Are you trying to create 301 surfaces? You can plot a single surface like this
surf(V.x, V.y, E(:,:,1))
To plot all 301 surfaces on single axes, use for loop
n = size(E,3);
figure;
ax = axes();
hold(ax)
for i=1:n
surf(V.x, V.y, E(:,:,i));
end
  3 个评论
Lucas Junghans
Lucas Junghans 2020-5-5
Ok. I guess i just solved my problem thanks to your answer :)
So thanks again.
n = size(E,3);
ax = axes();
hold(ax)
for i=1:n
surf(V.x, V.y, abs(squeeze(E(:,:,i).^2)),angle(squeeze(E(:,:,i).^2)));
end
Ameer Hamza
Ameer Hamza 2020-5-5
I am glad to be of help.
Yes. You can use surf to display a 4th-dimensional value on a surface.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by