I want to call multiple files and plot them using a loop

조회 수: 5 (최근 30일)
Zaryab Ali
Zaryab Ali 2021년 3월 24일
댓글: Zaryab Ali 2021년 3월 24일
Greetings
Lets say I have 'n' number of .mat files with random names, now, I want to call them, use some equations and plot them, but all on the same graph. Can I do that using a loop and make my life easier?
Right now I am calling them sperately like this (this is just for calling 1 file):
dirdata1 = dir('Smooth_cylinder_5ms_3D.mat');
file = dirdata1';
s = load(file.name);
L = extractfield(s,'b')';
a1 = s.b;
U_bar_2_1 = mean(a1)';
U_inf_2_1 = max(U_bar_2_1);
ud_2_1 = max(U_inf_2_1-U_bar_2_1);
yplus_2_1 = (y)/(nu/ud_2_1);
u_prime2_1 = [];
Uplus_2_1 = U_bar_2_1/ud_2_1;
..........
And then I plot using this(this is just for 1 file, it goes on until n number of files): Also I am running out of coloured lines how do I encounter that?
plot(y/D,U_bar_2_1/U_inf_2_1,'k-'...........

답변 (1개)

Mathieu NOE
Mathieu NOE 2021년 3월 24일
hello
attached a few examples - they are for excel / csv files but you can easily change the code for mat files (like : ... = uigetfile('*.mat')
hope it helps
  댓글 수: 1
Zaryab Ali
Zaryab Ali 2021년 3월 24일
I think I forgot to mention.. those .mat files are double i.e. they are a 491601x39 double files. So each file needs a seperate line plotted. And I want all those lines on the same figure with different colour.

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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by