Working on a simple chart plotter that uses data from a .csv, indexed by date (YYYY-MM-DD). The code so far is as follows:
clc
data = csvread('ArTP_Log_YYYY-MM-DD.csv',1,1); %.csv date should be defined by user input (YYYY-MM-DD)
plot(data(:,1),data(:,2:11))
title('Diode, Cryocooler Temps v. Time,',date)
xlabel('Time in ___ ') % collection rate should be defined by user input
ylabel('Temperature (K)')
legend('Stage 1','Stage 2','Stage 3','Stage 4','Cell','Strap','CuCollar','CuPlate','MT','CT')
I'd like to have the user input the date (format YYYY-MM-DD), and have it inserted into the file name (ArTP_Log_::date here::.csv). Also, I'd like the user to input a collection rate (ie Sec, H, Week, etc.) to be inserted into the xlabel field. Could I get some pointers? Thanks!

 채택된 답변

Vilém Frynta
Vilém Frynta 2023년 2월 9일
편집: Vilém Frynta 2023년 2월 9일

1 개 추천

Hello, hope this helps.
input_date = input("Choose date in YYYY-MM-DD format.","s") % save date as string
filename = "ArTP_Log_"; % default filename
filename_new = strcat(filename,input_date) % merge filename and date
collection_rate = input("Insert collection rate.","s")
Inputs do not work here in Matlab online but I think this should work. If you have a problem, feel free to comment.
Testing the code:
input_date = "2023-12-14";
collection_rate = "ABCDEF"; % i do not know what you wanna put here? but should be ok anyway
filename_new = strcat(filename,input_date)
filename_new = "ArTP_Log_2023-12-14"
figure
xlabel(collection_rate) % xlabel = ABCDEF

댓글 수: 3

Christopher
Christopher 2023년 2월 9일
Thanks, Vilem! Copied and modded just a bit, works perfectly!
Vilém Frynta
Vilém Frynta 2023년 2월 9일
Glad I could help.
If you are satisfied with my answer, I would be happy if you could formally accept it.
Sarah Gilmore
Sarah Gilmore 2023년 2월 10일
Hi Christopher,
To add to Vilém's answer, I would recommend using readmatrix with OutputType="datetime" instead of csvread because csvread is no longer recommended.
Best,
Sarah

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Calendar에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2023년 2월 9일

댓글:

2023년 2월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by