how can I process several files

조회 수: 6 (최근 30일)
Mostafa Elsayed
Mostafa Elsayed 2023년 7월 19일
댓글: Mostafa Elsayed 2023년 7월 19일
Helloe everyone,
please, how can I process all data using loop to avoid repeat text and also to plot all of their figures (2D and 3D)?
the code I use:

채택된 답변

VBBV
VBBV 2023년 7월 19일
편집: VBBV 2023년 7월 19일
You can use a for loop
tiledlayout('flow')
for k = 1 : 7
D = sprintf('PIVlab_%1d.mat',k)
hResult = surfheight(D,h0,H,n,[X0 Y0],'verbose','mask','nosetzero');
nexttile
imagesc(hResult.x,hResult.y,hResult.w)
end
D = 'PIVlab_1.mat'
D = 'PIVlab_2.mat'
D = 'PIVlab_3.mat'
D = 'PIVlab_4.mat'
D = 'PIVlab_5.mat'
D = 'PIVlab_6.mat'
D = 'PIVlab_7.mat'
  댓글 수: 4
VBBV
VBBV 2023년 7월 19일
편집: VBBV 2023년 7월 19일
Ok, if you want to generate figures separately for 2D & 3D then, you can use for loop counter in figure function
for k = 1 : 7
D = sprintf('PIVlab_%1d.mat',k)
hResult = surfheight(D,h0,H,n,[X0 Y0],'verbose','mask','nosetzero');
figure(k);
imagesc(hResult.x,hResult.y,hResult.w);
cmap1 = colormap('jet');
c1 = colorbar;
figure(k+1);
surf(X,Y,hResult.w.','FaceAlpha',1,'EdgeColor','interp')
cmap2 = colormap('jet');
c2 = colorbar;
end
Mostafa Elsayed
Mostafa Elsayed 2023년 7월 19일
thank you VBBV.
there is an error when I run the code, see below:
But I tried to modify a little bit the code (that you sent and mine) and now it works.
Thank you very much VBBV for your help and effort. see below the final working code:

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by