Finding NaN and Missing values from a mat cell matrix
15 Aug 2024
1 Answer
19 Views (30 days)
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
Hello, I have obtained a global matrix from an analysis (which is attached here and it is a reduced matrix as it is exceeded the 5mb) and I would like to find the NaN and missing values for each case to sort out some issues in the code for those values before generating a more complex simulation analysis. As you will see in the mat file there are 70 columns with separate information and each row is identified by the 1st column as it is related to the unique event of my database. I would like to generate two tables with the following information:
1st table containing the summary information of NaN values values in the whole matrix (attched file, that it may not contain NaN values as I have to reduce the number of rows for exceeding the 5mb) where it provides their location based on the row (first column: date_event) that provides the date_event, the name of the station provided in colum 46, and the column of the variable that has the NaN value. For example:
matrix_NaN=['1985-03-03 22:47:08', 'CFLAN,', 'Rrup1'; '1997-02-19 18:25:14','CPLAT', 'Rx'; ..........]
2nd table containing the information of missing values like it was provided with the NaN values:
matrix_missing=['2003-08-26 21:11:35', 'CFLAN,' 'Rx'; '2003-08-26 21:11:35','CTRUJ', sigma_Rx'; ..........]
I would appreciate the help
1 Comment
Stephen23
on 15 Aug 2024
Why is this data inefficiently stored as lots and lots of scalar arrays inside a cell array?
Using one table would be much more efficient, and offer much easier ways to process the data.
Accepted Answer
Voss
on 15 Aug 2024
load('example_global.mat')
C = example_global
C = 200x70 cell array
Columns 1 through 9
{'date_event' } {'lat_event'} {'lon_event'} {'Depth' } {'Altitude'} {'Magnitude'} {'Magnitude Type'} {'date_GMM' } {'Mw_GMM'}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
{[03-Mar-1985 22:47:08]} {[ -33.1960]} {[ -71.8645]} {[33.6667]} {[ -314]} {[ 7.9500]} {'Mw' } {[03-Mar-1985 22:47:08]} {[8.1600]}
Columns 10 through 20
{'Mw_type_GMM'} {'lat_GMM' } {'lon_GMM' } {'depth_GMM'} {'Alt_GMM' } {'str_GMM'} {'dip_GMM'} {'rake_GMM'} {'N segments'} {'M_GMM' } {'M_type_GMM'}
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
{'Mw' } {[-33.1250]} {[-71.6100]} {[ 40]} {[231.1200]} {[ 5]} {[ 25]} {[ 115]} {[ 2]} {[8.1600]} {'Mw' }
Columns 21 through 32
{'FM'} {'ETC'} {'Fact_GMM'} {'mpr_GMM'} {'mrr_GMM'} {'mrt_GMM'} {'mtp_GMM'} {'mtt_GMM'} {'str1_GMM'} {'dip1_GMM'} {'rake1_GMM'} {'str2_GMM'}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
{[ 2]} {[ 0]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ 5]} {[ 25]} {[ 115]} {[ -999]}
Columns 33 through 41
{'dip2_GMM'} {'rake2_GMM'} {'Dip_slab'} {'Strike Slab'} {'Slab Thickness'} {'Surface Slab'} {'Slab_model_used'} {'flag_source'} {'Check_CMT'}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
{[ -999]} {[ -999]} {[ 22.1954]} {[ 2.6961]} {[ 71.9672]} {[ -35.0212]} {[ 1]} {[ 2]} {[ -1]}
Columns 42 through 52
{'Check_ISC'} {'Check_USGS'} {'Source'} {'Network'} {'Station'} {'Lat_station'} {'Lon_Stat'} {'Alt_Stat'} {'Epi_dist'} {'Hyp_Dist1'} {'Hyp_Dist2'}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'BIOB01S'} {[ -36.5972]} {[-72.1150]} {[119.3403]} {[388.8286]} {[ 390.8807]} {[ 390.8692]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'MAUL02S'} {[ -35.9670]} {[-72.3101]} {[ 151]} {[322.4486]} {[ 324.9201]} {[ 324.9103]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'MAUL03R'} {[ -35.4299]} {[-71.6649]} {[102.9564]} {[256.3403]} {[ 259.4424]} {[ 259.4226]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'MAUL03S'} {[ -35.6939]} {[-71.4197]} {[255.4769]} {[286.1801]} {[ 288.9620]} {[ 288.9653]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'MAUL04S'} {[ -35.3297]} {[-72.4116]} {[ 15.2381]} {[255.9900]} {[ 259.0963]} {[ 259.0631]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'MAUL05S'} {[ -35.0099]} {[-71.9303]} {[ 52.8967]} {[211.6572]} {[ 215.4038]} {[ 215.3707]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'MAUL06S'} {[ -34.9581]} {[-72.1833]} {[ 46.3886]} {[210.5596]} {[ 214.3253]} {[ 214.2909]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'RANC02S'} {[ -34.5864]} {[-70.9831]} {[343.9395]} {[172.5024]} {[ 177.0793]} {[ 177.1048]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'RANC03S'} {[ -34.3904]} {[-72.0033]} {[ 27.9503]} {[145.3275]} {[ 150.7318]} {[ 150.6780]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'SERE02R'} {[ -31.6335]} {[-71.1678]} {[ 313]} {[170.9607]} {[ 175.5778]} {[ 175.5965]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'SERE02S'} {[ -31.9167]} {[-71.5106]} {[ 26.4620]} {[134.6836]} {[ 140.4980]} {[ 140.4398]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'STGO01S'} {[ -33.6867]} {[-71.2140]} {[170.0947]} {[ 72.4710]} {[ 82.7771]} {[ 82.7476]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'STGO03S'} {[ -33.4447]} {[-70.6453]} {[559.4652]} {[ 96.4594]} {[ 104.4242]} {[ 104.5504]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'VALP04S'} {[ -32.8444]} {[-70.9422]} {[391.7292]} {[ 69.6606]} {[ 80.3281]} {[ 80.4082]}
{[ 0]} {[ -1]} {'SCCMOD'} {'VDC' } {'VALP05S'} {[ -33.1933]} {[-71.6975]} {[ 56.6179]} {[ 11.1390]} {[ 41.5220]} {[ 41.3539]}
Columns 53 through 61
{'Rrup1' } {'Rrup2' } {'Rjb' } {'Rx' } {'Ztor' } {'L_mean_simul'} {'W_mean_simul'} {'strike_mean_Simul'} {'dip_mean_Simul'}
{[224.2996]} {[224.3135]} {[222.4764]} {[ 80.7423]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[155.7904]} {[155.8110]} {[154.2812]} {[ 57.7817]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 99.3892]} {[ 99.4280]} {[ 89.5526]} {[111.2476]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[129.4190]} {[129.5153]} {[116.8260]} {[135.5141]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 86.3396]} {[ 86.3425]} {[ 84.5206]} {[ 42.8911]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 53.6256]} {[ 53.6513]} {[ 45.1938]} {[ 83.6549]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 47.0170]} {[ 47.0379]} {[ 41.6533]} {[ 60.2189]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 70.3862]} {[ 70.6829]} {[ 31.1724]} {[166.4683]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 25.8137]} {[ 25.8417]} {[ 0]} {[ 71.5984]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[106.3266]} {[106.4506]} {[ 94.8390]} {[125.6876]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 69.2982]} {[ 69.3093]} {[ 60.6920]} {[ 95.7789]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 55.5356]} {[ 55.6827]} {[ 1.4963]} {[138.1906]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 81.8084]} {[ 82.2421]} {[ 51.7397]} {[188.8739]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 64.1955]} {[ 64.5351]} {[ 18.6445]} {[156.6714]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
{[ 30.8117]} {[ 30.8607]} {[ 0]} {[ 89.3293]} {[6.4000]} {[ 255]} {[ 165]} {[ 5]} {[ 25]}
Columns 62 through 70
{'sigma_Rrup1'} {'sigma_Rrup2'} {'sigma_Rjb'} {'sigma_Rx'} {'sigma_Ztor'} {'sigma_L'} {'sigma_W'} {'sigma_strike'} {'sigma_dip'}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
{[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]} {[ -999]}
As you said, the cell array in the attached mat file doesn't have any NaNs, so I'm going to introduce some for testing/demonstration purposes, to show that the distinction between NaN and <missing> can be made:
C{5,5} = NaN; % introducing NaNs for testing/demonstration
C{100,60} = NaN;
Now, construct a cell array containing info about the NaN and missing values, with 3 columns (corresponding datetime value, "variable" name, and value - either NaN or <missing>):
[ridx,cidx] = find(cellfun(@(x)any(ismissing(x)),C));
lidx = sub2ind(size(C),ridx,cidx);
C_missing = [C(ridx,1) C(1,cidx).' C(lidx)];
disp(C_missing)
{[03-Mar-1985 22:47:08]} {'Altitude' } {[ NaN]}
{[25-Jan-1999 18:19:17]} {'Rx' } {[<missing>]}
{[25-Jan-1999 18:19:17]} {'Rx' } {[<missing>]}
{[25-Jan-1999 18:19:17]} {'Rx' } {[<missing>]}
{[25-Jan-1999 18:19:17]} {'Rx' } {[<missing>]}
{[25-Jan-1999 18:19:17]} {'Rx' } {[<missing>]}
{[15-May-1999 10:20:38]} {'Rx' } {[<missing>]}
{[15-May-1999 10:20:38]} {'Rx' } {[<missing>]}
{[15-May-1999 10:20:38]} {'Rx' } {[<missing>]}
{[24-Jul-2001 05:00:13]} {'Rx' } {[<missing>]}
{[24-Jul-2001 05:00:13]} {'Rx' } {[<missing>]}
{[24-Jul-2001 05:00:13]} {'Rx' } {[<missing>]}
{[26-Aug-2003 21:11:35]} {'Rx' } {[<missing>]}
{[26-Aug-2003 21:11:35]} {'Rx' } {[<missing>]}
{[26-Aug-2003 21:11:35]} {'Rx' } {[<missing>]}
{[03-Sep-2000 05:03:25]} {'strike_mean_Simul'} {[ NaN]}
{[25-Jan-1999 18:19:17]} {'sigma_Rx' } {[<missing>]}
{[25-Jan-1999 18:19:17]} {'sigma_Rx' } {[<missing>]}
{[25-Jan-1999 18:19:17]} {'sigma_Rx' } {[<missing>]}
{[15-May-1999 10:20:38]} {'sigma_Rx' } {[<missing>]}
{[24-Jul-2001 05:00:13]} {'sigma_Rx' } {[<missing>]}
{[26-Aug-2003 21:11:35]} {'sigma_Rx' } {[<missing>]}
If you need to split it into two cell arrays, one for the NaNs and one for the <missing>s, you can do so like this:
nan_rows = cellfun(@isnumeric,C_missing(:,3));
matrix_NaN = C_missing(nan_rows,[1 2]);
matrix_missing = C_missing(~nan_rows,[1 2]);
disp(matrix_NaN)
{[03-Mar-1985 22:47:08]} {'Altitude' }
{[03-Sep-2000 05:03:25]} {'strike_mean_Simul'}
disp(matrix_missing)
{[25-Jan-1999 18:19:17]} {'Rx' }
{[25-Jan-1999 18:19:17]} {'Rx' }
{[25-Jan-1999 18:19:17]} {'Rx' }
{[25-Jan-1999 18:19:17]} {'Rx' }
{[25-Jan-1999 18:19:17]} {'Rx' }
{[15-May-1999 10:20:38]} {'Rx' }
{[15-May-1999 10:20:38]} {'Rx' }
{[15-May-1999 10:20:38]} {'Rx' }
{[24-Jul-2001 05:00:13]} {'Rx' }
{[24-Jul-2001 05:00:13]} {'Rx' }
{[24-Jul-2001 05:00:13]} {'Rx' }
{[26-Aug-2003 21:11:35]} {'Rx' }
{[26-Aug-2003 21:11:35]} {'Rx' }
{[26-Aug-2003 21:11:35]} {'Rx' }
{[25-Jan-1999 18:19:17]} {'sigma_Rx'}
{[25-Jan-1999 18:19:17]} {'sigma_Rx'}
{[25-Jan-1999 18:19:17]} {'sigma_Rx'}
{[15-May-1999 10:20:38]} {'sigma_Rx'}
{[24-Jul-2001 05:00:13]} {'sigma_Rx'}
{[26-Aug-2003 21:11:35]} {'sigma_Rx'}
2 Comments
Jorge Luis Paredes Estacio
on 15 Aug 2024
Thank you very much. I really appreciated :).
Voss
on 15 Aug 2024
You're welcome!
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)