【问题标题】:How to create a matrix in matlab using variables?如何在matlab中使用变量创建矩阵?
【发布时间】:2019-02-21 18:15:27
【问题描述】:

我有四个使用 NetCDF 数据创建的变量,即 高度、纬度、经度和日期。 现在我想创建一个将这些变量作为一列的矩阵,然后我应该忽略包含“NAN”数据的值。

我已经单独完成了这项工作,但我想要在一个矩阵中。 我必须在多个文件上运行这个过程。

for i = 1:length(theFiles)% Loop for each nc-file
    %Select Single cycle
    FileName = theFiles(i).name; 

    FullPathName=fullfile(folder_name, FileName); %reading file one by one
    disp(['File selected:', FullPathName])


    [Height,time,Lat,Long]=read_netcdf(FullPathName);  % Read the selected nc file 
     lattiude=Lat;
     longitude=Long;

     B = [Height,time,Lat,Long];   
    end 

还有一件事,完全没有。数据是 579X1 所有变量,但是当我从高度中删除 Nan 值时,它的尺寸减小到 45X1 现在我要做的是减少所有变量尺寸 w.r.t 高度。

我有我的矩阵,现在想删除所有包含 Nan Value 的行

NaN 736536.710457717 28.3771283105297 69.6958150783291 南 736536.710457858 28.3778490697636 69.6956231314990
75 736536.710458284 28.3800119048871 69.6950471308031 75 736536.710458426 28.3807327583405 69.6948551510433 南 736536.710458000 28.3785699096006 69.6954311612445 南 736536.710458142 28.3792909110158 69.6952391459993

【问题讨论】:

  • 我正在处理 Sentinel 3 的 NetCDF 文件。它包含水位信息,我需要的是一个包含 NAN 以外的单个矩阵。

标签: matlab netcdf


【解决方案1】:

不确定这是否是您所要求的,但您可以像这样增加数组的大小:

for i = 1:n
   B = [B; newValue];
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-10
    • 2014-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-04
    相关资源
    最近更新 更多