Multiple 2D in 3D Plot
이전 댓글 표시
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
darova
2020년 2월 12일
Where is the data? Can't run without variables C and C_Dim
Mustafa Ucar
2020년 2월 12일
darova
2020년 2월 12일
Please post it here
darova
2020년 2월 12일
Use attachments button if it's large
Mustafa Ucar
2020년 2월 12일
darova
2020년 2월 12일
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
채택된 답변
추가 답변 (2개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
