Hi, I am wondering if I have two values
x=[1,2,3,4,5,6,7]
y=[10,20,22,25,30,35,37]
I understand, it does NOT work like that, but could anyone help me to to do the same figure but with the data on the righthand side Y..
I need my plot to look like the same ??

2 件のコメント

Ali Tawfik
Ali Tawfik 2020 年 5 月 27 日
Another question, I read about slice, but I do not usually understand what is V ??
Ameer Hamza
Ameer Hamza 2020 年 5 月 28 日
You need at least 4 variables (3 independent and 1 dependent) to use slice(). V corresponds to the color of slices.

サインインしてコメントする。

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 28 日

0 投票

Try this
[X, Y, Z] = meshgrid(0:0.5:20, 0:0.5:20, 1:7);
V = exp(-0.2*sqrt((X-10).^2+(Y-10).^2+(2*(Z-4)).^2)); % based on guess
slice(X, Y, Z, V, [], [], 1:7)
colormap(jet)
shading interp
view([45 10])

6 件のコメント

Ali Tawfik
Ali Tawfik 2020 年 5 月 29 日
Hi,
Thanks for your help, it's great man, but could I add an axis on the right side with number for each stack layer ??
May also to define a shape for each stack layer or color then add color bar with label ?
Also, could I add labels ?? for each axis ?
Looking to hearing your reply.
Ameer Hamza
Ameer Hamza 2020 年 5 月 29 日
"could I add an axis on the right side with number for each stack layer ??"
Not easy to do programmatically, I suggest you add those labels using textboxes manually. In the figure window, go to the "insert" menu and click "Textbox". You can then you can manually click the position where you want to add the textbox.
The following code adds colorbar and the labels on each axes.
[X, Y, Z] = meshgrid(0:0.5:20, 0:0.5:20, 1:7);
V = exp(-0.2*sqrt((X-10).^2+(Y-10).^2+(2*(Z-4)).^2)); % based on guess
slice(X, Y, Z, V, [], [], 1:7)
colormap(jet)
shading interp
view([45 10])
colorbar;
xlabel('x');
ylabel('y');
zlabel('z');
Ali Tawfik
Ali Tawfik 2020 年 5 月 29 日
Thank you so much,
I also asked to add label or specific color for each stack layer ?
Is it possible or even a direction for each stack layer ? hope so
thank you so much.. Your answer always appericated. :)
Ameer Hamza
Ameer Hamza 2020 年 5 月 29 日
Can you elaborate on what do you mean by the labels or colors for each stack layer? Are you talking about numbers 12, 20, 22, 23, ... in red boxes in the original image? If yes, then the easiest way is to add them manually using textboxes, as mentioned in my last comment?
Ali Tawfik
Ali Tawfik 2020 年 5 月 29 日
Like I have 7 stack layers, so I would like 7 different colors or lets say 2 of them with same colors and the rest (5 stack layers with another color) as the following:
Stack layer 1 (red)
Stack layer 2 (blue)
Stack layer 3 (red)
Stack layer 4 (red)
Stack layer 5 (black)
Stack layer 6 (blue)
Stack layer 7 (green)
it's like in plot function when you define the line color as the following:
plot(x,y,'r') it means red for these points and so on....
Ameer Hamza
Ameer Hamza 2020 年 5 月 29 日
Although possible, there is no straightforward way. It cannot be done the same as passing color to plot(). The following threads will be helpful, but it will require some digging around.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by