Create the columns as a table, then add the column names as variable names. Use writetable to save it as a file.
How to add Labels to Files saving as .txt
3 次查看(过去 30 天)
显示 更早的评论
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')
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!