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개)
Star Strider
2021년 1월 24일
Create the columns as a table, then add the column names as variable names. Use writetable to save it as a file.
댓글 수: 0
참고 항목
카테고리
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!