how to use pcshow to plot a graph made of the same variable point?
15 次查看(过去 30 天)
显示 更早的评论
Hi! I have to plot a 3D graph using pcshow function where all the points come from the same point P made of three variable coordinates. So X Y Z are the three coordinates depending on 6 variables each. I wrote a code, but I'm just able to find all the possible values of P and plotting just the last of them, while I need to plot them all in the same graph to make something that should look like a sphere. I think that I should just need to understand or how to store all the possible P values (over 4 billion in my computation), or how to put in the graph the actual P values and then next and so on. I'll add my code here. Thank you very much!
for t1=0:10:380
for t2=0:10:360
for t3=0:10:570
for t4=0:10:380
for t5=0:10:360
for t6=0:10:380
X=95*sind(t1) + 540*cosd(t1)*cosd(t2) + 150*cosd(t4)*sind(t1) + 160*sind(t5)*(sind(t1)*sind(t4) - cosd(t4)*(cosd(t1)*sind(t2)*sind(t3) + cosd(t1)*cosd(t2)*cosd(t3))) + 160*cosd(t5)*(cosd(t1)*cosd(t2)*sind(t3) - cosd(t1)*cosd(t3)*sind(t2)) + 150*sind(t4)*(cosd(t1)*sind(t2)*sind(t3) + cosd(t1)*cosd(t2)*cosd(t3)) + 540*cosd(t1)*cosd(t2)*sind(t3) - 540*cosd(t1)*cosd(t3)*sind(t2);
Y=540*cosd(t2)*sind(t1) - 150*cosd(t1)*cosd(t4) - 95*cosd(t1) - 160*sind(t5)*(cosd(t1)*sind(t4) + cosd(t4)*(sind(t1)*sind(t2)*sind(t3) + cosd(t2)*cosd(t3)*sind(t1))) + 160*cosd(t5)*(cosd(t2)*sind(t1)*sind(t3) - cosd(t3)*sind(t1)*sind(t2)) + 150*sind(t4)*(sind(t1)*sind(t2)*sind(t3) + cosd(t2)*cosd(t3)*sind(t1)) + 540*cosd(t2)*sind(t1)*sind(t3) - 540*cosd(t3)*sind(t1)*sind(t2);
Z=540*sind(t2) + 540*cosd(t2)*cosd(t3) + 540*sind(t2)*sind(t3) + 160*cosd(t5)*(cosd(t2)*cosd(t3) + sind(t2)*sind(t3)) - 150*sind(t4)*(cosd(t2)*sind(t3) - cosd(t3)*sind(t2)) + 160*cosd(t4)*sind(t5)*(cosd(t2)*sind(t3) - cosd(t3)*sind(t2)) + 245;
P=[X Y Z];
pcshow(P)
end
end
end
end
end
end
0 个评论
采纳的回答
Walter Roberson
2021-11-25
step = 30;
v380 = 0:step:380;
v360 = 0:step:360;
v570 = 0:step:570;
[t1, t2, t3, t4, t5, t6] = ndgrid(v380, v360, v570, v380, v360, v380);
X = 95*sind(t1) + 540*cosd(t1).*cosd(t2) + 150*cosd(t4).*sind(t1) + 160*sind(t5).*(sind(t1).*sind(t4) - cosd(t4).*(cosd(t1).*sind(t2).*sind(t3) + cosd(t1).*cosd(t2).*cosd(t3))) + 160*cosd(t5).*(cosd(t1).*cosd(t2).*sind(t3) - cosd(t1).*cosd(t3).*sind(t2)) + 150*sind(t4).*(cosd(t1).*sind(t2).*sind(t3) + cosd(t1).*cosd(t2).*cosd(t3)) + 540*cosd(t1).*cosd(t2).*sind(t3) - 540*cosd(t1).*cosd(t3).*sind(t2);
Y = 540*cosd(t2).*sind(t1) - 150*cosd(t1).*cosd(t4) - 95*cosd(t1) - 160*sind(t5).*(cosd(t1).*sind(t4) + cosd(t4).*(sind(t1).*sind(t2).*sind(t3) + cosd(t2).*cosd(t3).*sind(t1))) + 160*cosd(t5).*(cosd(t2).*sind(t1).*sind(t3) - cosd(t3).*sind(t1).*sind(t2)) + 150*sind(t4).*(sind(t1).*sind(t2).*sind(t3) + cosd(t2).*cosd(t3).*sind(t1)) + 540*cosd(t2).*sind(t1).*sind(t3) - 540*cosd(t3).*sind(t1).*sind(t2);
Z = 540*sind(t2) + 540*cosd(t2).*cosd(t3) + 540*sind(t2).*sind(t3) + 160*cosd(t5).*(cosd(t2).*cosd(t3) + sind(t2).*sind(t3)) - 150*sind(t4).*(cosd(t2).*sind(t3) - cosd(t3).*sind(t2)) + 160*cosd(t4).*sind(t5).*(cosd(t2).*sind(t3) - cosd(t3).*sind(t2)) + 245;
P = [X(:), Y(:), Z(:)];
size(P)
uP = uniquetol(P, 'byrows', true);
size(uP)
pcshow(uP);
3 个评论
Walter Roberson
2021-11-25
You will find that at 10 degrees that the array sizes are huge. But notice that after taking unique that you reduce by a factor of 20 or so. This suggests a strategy of running batches of values for partial coverage, taking unique, storing that, then running the next batch, taking unique of that and what was already stored, and so on. For example the next batch might start at 10:step and the one after that at 20:step.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
