Selecting a file to create a plot on MATLAB

Hello, all!
I'm putting together script to create a plot from date logged via pytthon. Here is what I have so far:
data = csvread('ArTP_Log_2023-01-31_Matlab.csv',11); % Read the data
t = data(:,1) ;
a = data(:,2) ;
b = data(:,3) ;
c = data(:,4) ;
d = data(:,5) ;
e = data(:,6) ;
f = data(:,7) ;
g = data(:,8) ;
h = data(:,9) ;
i = data(:,10) ;
j = data(:,11) ;
plot(t,a,t,b,t,c,t,d,t,e,t,f,t,g,t,h,t,i,t,j)
legend('Stage 1','Stage 2','Stage 3','Stage 4','Strap','Cell','Copper Collar','Copper Plate','MT','CT')
It runs and plots just fine, though I'm thinking of adding elements later on. Primarily, I'm wondering how to be able to select a file rather than use the line 'data = csvread('file' , 'range')' and have to manually insert filename and range. Any thoughts? Any help is appreciated!

3 件のコメント

Voss
Voss 2023 年 2 月 2 日
Note that all of this:
t = data(:,1) ;
a = data(:,2) ;
b = data(:,3) ;
c = data(:,4) ;
d = data(:,5) ;
e = data(:,6) ;
f = data(:,7) ;
g = data(:,8) ;
h = data(:,9) ;
i = data(:,10) ;
j = data(:,11) ;
plot(t,a,t,b,t,c,t,d,t,e,t,f,t,g,t,h,t,i,t,j)
Can be replaced by this:
plot(data(:,1),data(:,2:11))
Christopher
Christopher 2023 年 2 月 2 日
Awesome! That will clean things up
Rik
Rik 2023 年 2 月 7 日
@Christopher did you see either answer below? You should consider marking one of them as accepted answer, or comment with the remaining issue.

サインインしてコメントする。

回答 (2 件)

Voss
Voss 2023 年 2 月 2 日

1 投票

uigetfile is the standard way to prompt the user to select a file.
Rik
Rik 2023 年 2 月 2 日

0 投票

You mean like uigetfile and prompt?

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

製品

リリース

R2021a

タグ

質問済み:

2023 年 2 月 2 日

コメント済み:

Rik
2023 年 2 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by