WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Cube 3D plot

 

bobotic
Forum-Anfänger

Forum-Anfänger


Beiträge: 19
Anmeldedatum: 22.10.15
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 17.05.2017, 23:59     Titel: Cube 3D plot
  Antworten mit Zitat      
I have a cube with spheres.
I want to plot it 3D.

Code:
N=15;
d=10;

xmax=d/2;
ymax=xmax;


rmin=0.5;
rmax=0.8;

Xmax=xmax - rmax;  
Ymax=ymax - rmax;

zufalls_radius = rmin+rand(N,1)*(rmax-rmin);
zufalls_height = 2*Xmax*rand(N,1);

X = 2*Xmax*rand(N,1)-Xmax;
Y = 2*Ymax*rand(N,1)-Ymax;

punkte=[X,Y,zufalls_height,zufalls_radius];


figure(1)
hold on  
Xmaxs = Xmax + rmax;
Ymaxs = Ymax + rmax;
rect1 = rectangle('Position',[-Xmaxs -Ymaxs 2*Xmaxs 2*Ymaxs])
axis equal
set(rect1, 'FaceColor', [0.4 0.4 0.6]);
plot(X,Y,'r*')
% axis equal
% xlim([-xmax,xmax]);ylim([-ymax,ymax])
for i=1:N

hold on
th = 0:pi/50:2*pi;
xunit = zufalls_radius(i) * cos(th) + X(i);
yunit = zufalls_radius(i) * sin(th) + Y(i);
sphere=plot(xunit, yunit)

end

for i=1:N

xunit = X(i) - zufalls_radius(i);
yunit = Y(i) - zufalls_radius(i);
ws = 2 * zufalls_radius(i);
hs = ws;

rectangle('Position',[xunit,yunit,ws,hs],'Curvature',[1,1], 'FaceColor',[0.8 0.4 0.4])
axis square;
    xlabel('X [mm]');
    ylabel('Y [mm]');
end


[EDITED, Jan, Bitte Code-Umgebung verwenden - Danke!]
Private Nachricht senden Benutzer-Profile anzeigen


Knygs
Forum-Fortgeschrittener

Forum-Fortgeschrittener


Beiträge: 58
Anmeldedatum: 26.03.15
Wohnort: ---
Version: 2015b, 2017a, 2021a
     Beitrag Verfasst am: 20.05.2017, 11:23     Titel:
  Antworten mit Zitat      
eg you can use
Code:

or
Code:

of course you have to calculate in 3-Dimensions then
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.