[英]How to create a matrix in matlab using variables?
我有四個使用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所有變量,但是當我從Height中刪除Nan值時,其尺寸減小為45X1現在,我要嘗試的是減小所有變量的尺寸wrt Height。
我有我的矩陣,現在想刪除所有包含Nan Value的行
NaN 736536.710457717 28.3771283105297 69.6958150783291 NaN 736536.710457717 28.3778490697636 69.6956231314990
75 736536.710458284 28.3800119048871 69.6950471308031 75 736536.710458426 28.3807327583405 69.6948551510433 NaN 736536.710458000 28.3785699096006 69.6954311612445 NaN 736536.710458142 28.3792909110158 69.6952391459993
不知道這是否是您要的內容,但是您可以像這樣增加數組的大小:
for i = 1:n
B = [B; newValue];
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.