create plot with slice
20 ビュー (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/303931/image.png)
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 件のコメント
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
2020 年 5 月 28 日
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])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/304251/image.png)
6 件のコメント
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 件)
参考
カテゴリ
Help Center および File Exchange で Colorbar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!