I have to compare data from matrix with different dimensions
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
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 comentarios
Ameer Hamza
el 12 de Mzo. de 2020
Can you give an example with sample matrices A and B, and also explain your required output? Which line is giving the error? Attaching a sample dataset will also help.
Valerio Gianforte
el 12 de Mzo. de 2020
dpb
el 12 de Mzo. de 2020
Where's the second dataset and what is the wanted result from the two?
Look at ismember
Valerio Gianforte
el 12 de Mzo. de 2020
Respuestas (1)
dpb
el 12 de Mzo. de 2020
0 votos
Convert both to timetable or timeseries objects and use retime to synchronize the two.
7 comentarios
dpb
el 12 de Mzo. de 2020
"Aren't timeseries being deprecated"
Nothing in R2019b doc about. It's a hard one to know whether to use imo. It doesn't seem to really have much that I've found really totally not easy to have done without.
Valerio Gianforte
el 13 de Mzo. de 2020
Guillaume
el 13 de Mzo. de 2020
synchronize, timetable, etc. all work, you'd think by now somebody would have noticed if they didn't. Now, the way you tried to use them may not have worked but it's hard to tell what you did wrong if you don't tell us what you did.
Also, attach demo files rather than copy/pasting content. It's much easier for us to help you if we don't have to recreate your files just to figure out what to do.
Valerio Gianforte
el 13 de Mzo. de 2020
Guillaume
el 13 de Mzo. de 2020
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?
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!