MATLAB . I need someone to help me create an If statement inside my For Loop in a MATLAB script that I am writing. I am

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

MATLAB . I need someone to help me create an If statement inside my For Loop in a MATLAB script that I am writing. I am

Post by answerhappygod »

MATLAB . I need someone to help me create an If statement insidemy For Loop in a MATLAB script that I am writing. I am trying tohave MATLAB cycle through all of the 500 files of data I downloadedso that I can create a Matrix with all of the data. I haveeverything done except for 1 If statement I believe. With allthe data you can see that the file name changes from Merra2_100 toMerra2_200, it goes to 300, 400, and 401 as well. Please let meknow what if statement i should write for the code to understandthat i want all this data. nc files using ncread.
Matlab I Need Someone To Help Me Create An If Statement Inside My For Loop In A Matlab Script That I Am Writing I Am 1
Matlab I Need Someone To Help Me Create An If Statement Inside My For Loop In A Matlab Script That I Am Writing I Am 1 (105.42 KiB) Viewed 76 times
MERRA2_100.tavgM_2d_Ind_Nx.199102.nc4.nc4 MERRA2_100.tavgM_2d_Ind_Nx.199103.ne4.nc4 MERRAZ 100.tavgM_2d_Ind_Nx.199104.nc4.nc4 MERRA2_100.tavgM_2d_Ind_Nx.199105.ne4.nc4 MERRA2_100.tavgM_2d_Ind_Nx.199106.nc4.nc4 MERRAZ 100.tavgM_2d_Ind_Nx.199107.nc4.nc4 MERRA2_100.tavgM_2d_Ind_Nx.199108.nc4.nc4 MERRAZ 100.tavgM_2d_Ind_Nx.199109.nc4.nc4 MERRA2_100.tavgM_2d_Ind_Nx.199110.ne4.nc4 MERRA2_100.tavgM_2d_Ind_Nx.199111.nc4.nc4 MERRAZ 100.tavgM_2d_Ind_Nx.199112.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199201.nc4.nc4 MERRAZ_200.tavgM_2d_Ind_Nx.199202.nc4.nc4 MERRA2 200.tavgM_2d_Ind_Nx.199203.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199204.nc4.nc4 MERDAS MERRAZ 200.tavgM_2d_Ind_Nx.199205.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199206.nc4.nc4 MERRAZ_200.tavgM_2d Ind_Nx.199207.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199208.nc4.nc4 MERRA2 200.tavgM_2d_Ind_Nx.199209.nc4.nc4 MERRAZ 200.tavgM 2d Ind Nx.199210.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199211.nc4.nc4 MERRAZ_200.tavgM_2d_Ind_Nx.199212.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199301.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199302.ne4.nc4 MERRAZ_200.tavgM_2d_Ind_Nx.199303.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199304.nc4.nc4 MERRA2_200.tavgM_2d_Ind_Nx.199305.nc4.nc4 MERRAZ_200.tavgM_2d_Ind_Nx.199306.nc4.nc4 MERRA2 200.tavgM_2d_Ind_Nx.199307.nc4.nc4 LIPARA MERRA2_200.tavgM_2d_Ind_Nx.199201.nc4.nc4 (D... V No details available 6 7 8 9 18 11 12 13 14 15 16 17 18 19 28 21 22 Q 23 24 Q 25 26 27 28 29 38 31 32 33 34 35 36 37 38 39 Folder containing all M2 Data MZPPT_dir= latncread (IM2PPT_dir /MERRA2_180.tavgM_2d_lnd_Nx.198001.nc4.nc4'], 'lat') 1on cread [M2PPT_dir /MERRA2_180.tavgM_2d_Ind_Nx.198001.ne4.ne4'], "lon"> nlat length(lat) nlon length(lon) years 1988:2021; nyears length(years) (¹/Users/michellethienes/Desktop/NERRAZ_DATA/PrecipMZData/'> Initialize variables PPT NaN(nlat, nlon, 12, nyears); Have all times in the natrix using For Loop & ncread. for iyrs 1:nyears. for imon 1:12 Print the Loop index/counter to the screen disp(['iyrs: num2strliyrs)]) end end 0 if N2PPT_dir==('/MERRAZ 200.tavg_2d_lnd Nx!) displ['iyrs: nun2str(iyrs)]) else displl'iyrs: num2strliyrs!] PPT (:,:,imon, iyrs) = ncread( [M2PPT_dir /MERRAZ_100.tavgM_20_Ind_Nx. nun2str(years (iyrs)) sprintf('%02.1", inc- Command Window Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters. ||| ||| dir 1 361x1 double 576x1 double '/Users/michellet... 361 576 42 4-D double 1x42 double
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply