How to add Labels to Files saving as .txt

7 visualizaciones (últimos 30 días)
Brittany Isbister
Brittany Isbister el 24 de En. de 2021
Respondida: Star Strider el 24 de En. de 2021
Hi All,
I was trying to add labels to my columns of the files I'm saving as .txt. The files are the loadPhase and loadRelax I'm trying to add the column labels too. I tried to do x.properties.variables and that didn't work. I'm lost on any other ideas of how to add labels to the columns. My code is below. Any help would be appreciated! Thank you in advance! :)
load('experiment1.txt','-ascii')
%when you remove the % in the code it presents with an error this is because the % made it so matlab could read it.
Time=experiment1(:,1);
Load=experiment1(:,2);
Displacement=experiment1(:,3);
subplot(4,1,1);
plot(Displacement,Time)
xlabel('Time (seconds)')
ylabel('Displacement (Meters)')
title('Displacement vs Time')
subplot(4,1,2);
plot(Load,Time)
xlabel('Time (seconds)')
ylabel('Load (Joules)')
title('Load vs Time')
[M,I]=max(Load);
timep=(Time(1:1827));
timer=(Time(1828:9504));
loadp=(Load(1:1827));
loadr=(Load(1828:9504));
loadPhase=[timep,loadp];
loadRelax=[timer,loadr];
subplot(4,1,3)
plot(timep,loadp)
xlabel('Time (seconds)')
ylabel('Loading (Joules)')
title('Load vs Time for the Loading Phase')
save
subplot(4,1,4)
plot(timer,loadr)
xlabel('Time (seconds)')
ylabel('Loading (Joules)')
title('Load vs Time for the Relaxing Phase')
save('loaddata.txt','loadPhase','-ascii')
save('relaxdata.txt','loadRelax','-ascii')

Respuestas (1)

Star Strider
Star Strider el 24 de En. de 2021
Create the columns as a table, then add the column names as variable names. Use writetable to save it as a file.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by