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

采纳的回答

Walter Roberson
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)
ans = 1×2
7425860 3
uP = uniquetol(P, 'byrows', true);
size(uP)
ans = 1×2
219744 3
pcshow(uP);
Error using uicontrol
This functionality is not available on remote platforms.

Error in rotate3d>localCreateAzElIndicator (line 478)
rdata.ModeStateData.textBoxText = uicontrol('Parent',hFig,'Units','Pixels',...

Error in rotate3d>localDoRotateOn (line 508)
localCreateAzElIndicator(rdata)

Error in rotate3d>@(~,~)localDoRotateOn(rdata) (line 393)
set(rdata,'ModeStartFcn',@(~,~)localDoRotateOn(rdata));

Error in hgfeval (line 62)
feval(fcn{1},varargin{:},fcn{2:end});

Error in matlab.uitools.internal.uimode/modeControl (line 16)
hgfeval(hThis.ModeStartFcn);

Error in matlab.uitools.internal.uimode/set.Enable (line 167)
obj.Enable = modeControl(obj,value);

Error in matlab.uitools.internal.uimodemanager>localSetMode (line 200)
set(newMode,'Enable','on');

Error in matlab.uitools.internal.uimodemanager/set.CurrentMode (line 119)
obj.CurrentMode = localSetMode(obj,value);

Error in activateuimode (line 30)
set(hManager,'CurrentMode',hMode);

Error in rotate3d>setState (line 363)
activateuimode(fig,'Exploration.Rotate3d');

Error in rotate3d (line 262)
setState(hTarget,arg2,rotatestyle)

Error in pointclouds.internal.pcui.initializePCSceneControl>initUIMode (line 124)
rotate3d(pcAxes,'on');

Error in pointclouds.internal.pcui.initializePCSceneControl (line 12)
initUIMode(hFigure, pcAxes);

Error in pcshow (line 166)
pointclouds.internal.pcui.initializePCSceneControl(hFigure, currentAxes, hObj, vertAxis,...
  3 个评论
Walter Roberson
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.
Andrea Tonelli
Andrea Tonelli 2021-11-25
Ok thank you again. For my evaluation just the 0:step quite enough, but knowing it is always an improvement!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by