フィルターのクリア

There is colormap inconsistency in my graph for the code attatched.

1 回表示 (過去 30 日間)
KM
KM 2023 年 4 月 27 日
編集済み: KM 2023 年 5 月 5 日
Hi,
I used a package arrow3D. Here, I want the colormap on arrow to change with the variation in z-axis.
IANd since deltaV(3) is the z-direction. I tried passing it as
arrow3D(pos,deltaV,deltaV(3))
but it's not helping.
Thanks

回答 (1 件)

alexander Mcghee
alexander Mcghee 2023 年 4 月 27 日
編集済み: alexander Mcghee 2023 年 4 月 27 日
normalize the z-direction values between 0 and 1 so that they can be properly used to index the colormap.
pos = postot(ii,:)-.5*deltaV;
% Normalize the z-direction value between 0 and 1
z_norm = (deltaV(3) - min(deltaV0(3))) / (max(deltaV0(3)) - min(deltaV0(3)));
% Get the color from the colormap based on the normalized z-direction value
colorCode = colormap(jet(64));
arrowColor = colorCode(round(z_norm * 63) + 1, :);
arrow3D(pos, deltaV, arrowColor)
  1 件のコメント
KM
KM 2023 年 4 月 27 日
編集済み: KM 2023 年 4 月 28 日
@alexander Mcghee Thank you so much fo the response. I did try that as,
Normalize the z-direction value between 0 and 1
min_z = min(deltaV0(3));
max_z = max(deltaV0(3));
if deltaV(3) <= min_z
z_norm = 0;
elseif deltaV(3) >= max_z
z_norm = 1;
else
z_norm = (deltaV(3) - min_z) / (max_z - min_z);
end
% Get the color from the colormap based on the normalized z-direction value
colorCode = colormap(jet(64));
arrowColor = colorCode(round(z_norm * 63) + 1, :);
But the colour code is not working properly and sometimes giving an script index error. Could you please cross check.

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

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by