Multiple 2D in 3D Plot
Show older comments
Hi everyone,
I have a problem, how do I get my 2d plot what I created with the code in 3D. I would be happy if you could help me.
%Initalisieurung der globalen Variablen
global C_Dim C Bauteil L R1 R2 D
%Achsen für Berechnung
%2 Y Achsen für Innen und Außenradius
x= zeros(C_Dim(1,1)*4);
y= zeros(C_Dim(1,1)*4);
y2= zeros(C_Dim(1,1)*4);
%Variable für Startwert Dekleration mit Schleife für Durchgang aller
%Variablen
g = 1;
startwert = 0;
for i = 1: C_Dim(1,1)
Bauteil = char(C(i,1));
L = str2double(C(i,2));
R1 = str2double(C(i,3));
R2 = str2double(C(i,4));
x(g,1)= startwert;
x(g+1,1)=startwert+L;
%Fallunterscheidung der einzelnen Bauteile
switch Bauteil
case 'Z'
R1=R2;
%y-wert Außenradius
y(g,1)=R2;
y(g+1,1)=R2;
g=g+2;
startwert=startwert+L;
%Spiegelung der Figur
if i==C_Dim(1,1)
v=0;
for u=(i-1)*2:-1:1
v=v+1;
x((i-1)*2+v,1) = x(u,1);
y((i-1)*2+v,1) = -y(u,1);
y2((i-1)*2+v,1)= -y2(u,1);
end
x(end,1)=x(1,1);
y(end,1)=y(1,1);
y2(end,1)= y2(1,1);
end
%Case Z Ende
case 'K' %Abfrage Konus
y(g,1)=R1;
y(g+1,1)=R2;
g=g+2;
startwert=startwert+L;
%Spiegelung der Figur
if i==C_Dim(1,1)
v=0;
for u=(i-1)*2:-1:1
v=v+1;
x((i-1)*2+v,1) = x(u,1);
y((i-1)*2+v,1) = -y(u,1);
y2((i-1)*2+v,1)= -y2(u,1);
end
x(end,1)=x(1,1);
y(end,1)=y(1,1);
y2(end,1)= y2(1,1);
end
% Case K Ende
case 'HZ' %Abfrage Zylinder
y(g,1)=R2;
y(g+1,1)=R2;
y2(g,1)=R1;
y2(g+1,1)=R1;
g=g+2;
startwert=startwert+L;
%Spiegelung der Figur
if i==C_Dim(1,1)
v=0;
for u=(i-1)*2:-1:1
v=v+1;
x((i-1)*2+v,1) = x(u,1);
y((i-1)*2+v,1) = -y(u,1);
y2((i-1)*2+v,1)= -y2(u,1);
end
x(end,1)=x(1,1);
y(end,1)=y(1,1);
y2(end,1)= y2(1,1);
end
%Case Z Ende
end
%Ende Switch
%Bestimmung der Skalierung für die x-Achse bzw y-Achse
max_R1=max(str2double(C(:,3)));
max_R2=max(str2double(C(:,4)));
R_max=max(max_R1,max_R2);
%Skalierung y-Achse
y_max=(R_max)+100;
%Skalierung x-Achse
x_max=startwert+100;
end
%Plot
plot(x,y,'blue-',x,y2,'green--')
ylim([-y_max y_max]);
xlim([0 x_max])
Title=title('2D Darstellung des Rotorstrangs');
xlabel('Länge [mm]')
ylabel('Radius [mm]')
6 Comments
darova
on 12 Feb 2020
Where is the data? Can't run without variables C and C_Dim
Mustafa Ucar
on 12 Feb 2020
darova
on 12 Feb 2020
Please post it here
darova
on 12 Feb 2020
Use attachments button if it's large
Mustafa Ucar
on 12 Feb 2020
darova
on 12 Feb 2020
Maybe you can show the picture you have and the result you want to achieve
I don't think to attach 5 script is good idea
Accepted Answer
More Answers (2)
Mustafa Ucar
on 12 Feb 2020
0 votes
1 Comment
darova
on 12 Feb 2020
What do you want me to do with this?
Mustafa Ucar
on 12 Feb 2020
0 votes
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!