Info
此问题已关闭。 请重新打开它进行编辑或回答。
I have to compare data from matrix with different dimensions
1 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I have to compare the data of two matrix with different dimensions but without 'intersect' because I need every data. I tried to do a for loop and if condition but I obtaine the error 'Matrix dimension must agree'. Is there someone that can help me? I'm attacching my code below. Thanks.
format long g
folderData = 'D:\Valerio\data\ACCESS1.0';
filePattern = fullfile(folderData, '*.xlsx');
xlsFiles = dir(filePattern);
nFiles = length(xlsFiles);
for ii = 1:nFiles
filename = fullfile(xlsFiles(ii).folder, xlsFiles(ii).name);
files{ii} = xlsread(filename);
end
IPCC = files(1);
ERA5 = files(2);
Data_IPCC = IPCC{:,1};
Data_ERA5 = ERA5{:,1};
Years_IPCC = Data_IPCC(:,1);
Years_ERA5 = Data_ERA5(:,1);
range_IPCC = length(Years_IPCC);
range_ERA5 = length(Years_ERA5);
index_year = []
for i = 1:range_IPCC
for j = 1:range_ERA5
if Years_IPCC == Years_ERA5
index_year(i,j) = j
end
end
end
4 个评论
dpb
2020-3-12
Where's the second dataset and what is the wanted result from the two?
Look at ismember
回答(1 个)
dpb
2020-3-12
Convert both to timetable or timeseries objects and use retime to synchronize the two.
7 个评论
Guillaume
2020-3-13
I'm a bit unclear as to what the desired output is.
There are 64 dates of the ERA files not found in the ACCESS file, and 67 dates of the ACCESS file not found in the ERA files. How should identical be merge? What should be done about the dates not present in one file and not the other?
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!