How to plot 3d from a Table?
14 ビュー (過去 30 日間)
古いコメントを表示
Hello everybody,
I have a problem with my Code. I want to 3dplot from a table.My problem is, only the first line is plotted. I want all lines to be plotted. I'm new to Matlab, hope you can help me. This is my Code. It is in German. I hope you can understand this. In the first step i read a txt. file into Matlab. Then i change it to a vector element. Then i write it in a Matrix. My For LOop get into the first row. How can i go throught all rows?
global A B C D E F C_Dim Anzahl Bautyp L R1 R2 Rho G D_Dim D_berechnen
% Daten Einlesen
[filename, pathname]=uigetfile('*txt','Datei auswählen');%Auswählen von Datei
A=fopen(fullfile(pathname, filename),'r'); %Datei wird in matlab geöffnet
B=textscan(A, '%s %s %s %s %s %s '); %Text als Vektor einlesen
fclose(A); %Datei in matlab schließen
% Werte in eine Matrix schreiben
C = [B{1},B{2},B{3},B{4},B{5},B{6}]; % Variable C für Plot
D = [B{1},B{2},B{3},B{4},B{5},B{6}]; % Variable D für Tabelle
E = [B{1}];
F = str2double([B{1},B{2},B{3},B{4}]); %Für 3D Plot
F(1,:)=[]; %Für 3D Plot ohne Überschrift
Anzahl = length(E)-1; % -1, um die Überschrift aus der Anzahl der Bauteile zu entfernen
D_berechnen = str2double(D);
%Dimension der Matrix bestimmen
C_Dim = size(C);
D_Dim = size(D);
Title=title('3D Darstellung des Rotorstrangs');
xlabel('Länge [mm]')
ylabel('Radius [mm]')
zlabel('Radius [mm]')
box on
hold all
axis tight
set(gca,'XTickLabelRotation',-45);
set(gca,'YTickLabelRotation',45);
view(3);
rotate3d on;
ldavor = 0;
aktl = 0;
for i = 1: Anzahl
if strcmp( E(i),'HZ')
Innenradius = F(i,3);
Aussenradius = F(i,4);
Laenge = F(i,2);
% ------------------------Hochrechnen der aktuellen gesamte länge--------------------------%
aktl = ldavor+Laenge;
%--------------------------------ploten von hohlzylinder----------------------------------------%
[phi ,x] = meshgrid(0:2*pi/60:2*pi,ldavor:aktl);
%------------------------------ ploten von Außenzylinder-------------------------------------------------%
r1 = Aussenradius ;
z = r1* cos(phi);
y = r1*sin(phi);
surf(x,y,z);
hold on
%-------------------------------ploten von Innenzylinder----------------------------------------------------------%
r2 = Innenradius ;
z = r2*cos(phi);
y = r2*sin(phi);
surf(x,y,z);
hold on
%---------------------------------------------plotten von deckel links----------------------------------------------------%
r = Aussenradius;
[phi,r]= meshgrid(0:2*pi/60:2*pi,0:r:r);
y = r.*cos(phi) ;
Hilfe = ones(size(r));
x = Hilfe.*ldavor;
z = r.*sin(phi);
surf(x,y,z);
hold on
%-------------------------------------plotten deckel rechts-------------------------------------------%
r = Aussenradius;
[phi,r]= meshgrid(0:2*pi/60:2*pi,0:r:r);
y = r.*cos(phi) ;
Hilfe = ones(size(r));
x = Hilfe.*aktl;
z = r.*sin(phi);
surf(x,y,z);%
hold on
end
%colormap(jet);
shading interp
colorbar;
end
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!