Plot disappears when trying to interpolate
2 ビュー (過去 30 日間)
古いコメントを表示
Good afternoon,
In the code below for some weird reason i cant figure out how to interpolate the color so it changes as it extends away from (0,0,0), could you possibly tell me how I would be able to fix this?
clc; clear; close all;
i = 1;
PStress = zeros(134343,3);
Yieldstr = 1000; %KPa
minValue = -4*Yieldstr;
maxValue = 4*Yieldstr;
fidelity = Yieldstr/8; %We can adjust this to make cleaner graphs, might just take longer to run
for sigx = minValue:fidelity:maxValue
for sigy = minValue:fidelity:maxValue
for sigz = minValue:fidelity:maxValue
%Reduced to sig1-3
VM = (1/(sqrt(2)) * sqrt((sigx-sigy).^2 + (sigy-sigz).^2 +(sigz-sigx).^2));
if VM < Yieldstr
if (sigx==sigy) && (sigy==sigz) && (sigz==sigx)
%stops code
else
PStress(i,1) = sigx;
PStress(i,2) = sigy;
PStress(i,3) = sigz;
i = i + 1;
end
end
end
end
end
Data = sqrt(sigx.^2+sigy.^2+sigz.^2);
colormap cool
shading interp
D = alphaShape(PStress,inf);
plot(D,"FaceColor","none","EdgeColor","interp");
If you remove the edge color part you will see the plot comes back to its original shape. The goal is to have something that looks like this,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/740109/image.png)
Thanks for the time as always,
Kevin
0 件のコメント
採用された回答
Adam Danz
2021 年 9 月 15 日
編集済み: Adam Danz
2021 年 9 月 15 日
Plotting an alphaShape creates a patch object. When set to interp, the EdgeColor property requires existing CData or FaceVertexData prior to setting EdgeColor (see documentation). From your description, the interpolation should be based on distance to (0,0,0) so I've set CData to the distance of each vertex from (0,0,0).
i = 1;
PStress = zeros(134343,3);
Yieldstr = 1000; %KPa
minValue = -4*Yieldstr;
maxValue = 4*Yieldstr;
fidelity = Yieldstr/8; %We can adjust this to make cleaner graphs, might just take longer to run
for sigx = minValue:fidelity:maxValue
for sigy = minValue:fidelity:maxValue
for sigz = minValue:fidelity:maxValue
%Reduced to sig1-3
VM = (1/(sqrt(2)) * sqrt((sigx-sigy).^2 + (sigy-sigz).^2 +(sigz-sigx).^2));
if VM < Yieldstr
if (sigx==sigy) && (sigy==sigz) && (sigz==sigx)
%stops code
else
PStress(i,1) = sigx;
PStress(i,2) = sigy;
PStress(i,3) = sigz;
i = i + 1;
end
end
end
end
end
Data = sqrt(sigx.^2+sigy.^2+sigz.^2);
colormap cool
shading interp
D = alphaShape(PStress,inf);
h = plot(D, 'FaceColor', 'none');
distance = sqrt(sum(h.Vertices,2).^2);
h.CData = distance;
h.EdgeColor = 'interp';
cb = colorbar();
ylabel(cb, 'Distance');
xline(0, 'k:')
yline(0, 'k:')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!