Hello guys! I need a little help with 3d plotting. I need to do the coloring for the surface like this, but I cant get the yellowy parts to their correct positions.
1 回表示 (過去 30 日間)
古いコメントを表示
Tamás Zsombor Tolvaj
2022 年 4 月 13 日
コメント済み: Image Analyst
2022 年 4 月 13 日
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/963205/image.jpeg)
This is what I have done so far (first is the function calling code, it wasnt made by me, only the function):
x=-4:0.1:4;
y=-4:0.1:4;
[X, Y] = meshgrid(x,y);
Z = 2*(peaks(X, Y)-3);
[C,U,V,W,fig1,plt1,plt2,fig2,plt3,cl] = tengerpart(X,Y,Z)
function [C,U,V,W,fig1,plt1,plt2,fig2,plt3,cl] = tengerpart(X,Y,Z)
C=gradient(Z);
[U, V, W]=surfnorm(X, Y, Z);
U=U;
V=V;
W=W;
fig1=figure(1);
plt1=surf(X, Y, Z, C);
xlim([-5 5]);
ylim([-5 5]);
zlim([-20 15]);
hold on;
plt2=quiver3(X, Y, Z, U, V, W, 'r');
end
0 件のコメント
採用された回答
Daniel Vieira
2022 年 4 月 13 日
ok... what do you mean by "correct position" for the yellow parts? where is the correct?
strange things I noticed:
1) the "U=U; V=V; W=W" part means nothing, you can take that out.
2) when you do "C=gradient(Z);" you only get the x-component of the gradient, was that really your intention? to get both you shoud do "[Cx,Cy]=gradient(Z);".
4 件のコメント
Image Analyst
2022 年 4 月 13 日
@Tamás Zsombor Tolvaj, since it worked could you click the Accept this answer link to award @Daniel Vieira his "reputation points"? Thanks in advance. 🙂
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!