How to create plot from the data in .txt file ?
143 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rufiya
el 31 de Ag. de 2023
Comentada: Les Beckham
el 3 de Sept. de 2023
Hello All,
I wanted to create a 2D plot of spatial density versus altitude using the data in .txt file, however, when i tried converting first the data into excel format it did not work the best and eventually i could not do the necessary coding to read data from excel file to create the desired MATLAB plot as shown below.
Kindly could anyone let me know, if there is way you could suggest to directly create a 2D plot using the attached .txt file or at least convert them to excel format that can be coded in MATLAB to create the plot?
0 comentarios
Respuesta aceptada
Les Beckham
el 31 de Ag. de 2023
This should get you started. Note that the warnings are expected and can be ignored.
T = readtable('Spatial Density.txt', 'EmptyLineRule', 'skip', 'VariableNamesLine', 1);
% plot some of the data -- modify as desired
plot(T.Altitude, T.Expl_Fragm, T.Altitude, T.Coll_Fragm, T.Altitude, T.Launch_Mis)
grid on
legend(T.Properties.VariableNames, 'Interpreter', 'none')
7 comentarios
Más respuestas (1)
Zak
el 31 de Ag. de 2023
Would something like this work? You'll have to modify the plotting part to add the other columns. I'm sure there's some way to name the table variables from the text file, but I didn't quite figure it out yet.
T = readtable('Spatial Density.txt','NumHeaderLines',1);
figure
hold on
plot(T.Var1,T.Var2)
plot(T.Var1,T.Var3)
hold off
xlabel('altitude')
legend('Expl-Fragm','Coll-Fragm')
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!