issue while concatenating the matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Arvind Gauns
el 30 de Jun. de 2022
Comentada: KSSV
el 30 de Jun. de 2022
This is the code which I am using
%%
clear all
clc
[file_list, path_n] = uigetfile('final*.mat', 'Grab all the files', 'MultiSelect','on');
if ischar(file_list); file_list = {file_list}; end %only one selected
if ~iscell(file_list); return; end %user cancel
ii=1
for i = 1:length(file_list)
this_file = fullfile(path_n, file_list{i});
loadfile = load(this_file);
s = struct(loadfile);
h = loadfile.o2a_s ;
jj = h(:,1);
z = datenum(h(:,2),'HH:MM');
h(:,2)=[];
KK = str2double(h);
%finding ths number of rows and columns
[R C]=size(KK);
% assigning a zero matrix gg of the given size
gg=zeros(1,5);
%% everything is working fine as per needed till here but from here i am facing troubles
j=1;
for ii=1:(R-1);
%%
if z(ii,1)>= [738522.558] while z(ii,1)<= [738522.566]
gg=[gg;KK(ii,:)];
end
end
end
end
% dd(1,:) = [];
the files are in Mat format. the file type is string.
i want values of z in such manner z(ii,1)>= [738522.558] while z(ii,1)<= [738522.566]
the problem is the code is running fine but ti am not able to retrieve the gg matrix at the end. ( rather i am getting the values corresponding to the last file inputted to the loop)
2. I want to include the file name corresponding to the ii value in the gg matrix. how to modify the code for the same ?
2 comentarios
Respuesta aceptada
KSSV
el 30 de Jun. de 2022
Editada: KSSV
el 30 de Jun. de 2022
[file_list, path_n] = uigetfile('final*.mat', 'Grab all the files', 'MultiSelect','on');
if ischar(file_list); file_list = {file_list}; end %only one selected
if ~iscell(file_list); return; end %user cancel
N = length(file_list) ;
iwant = cell(N,1) ;
for i = 1:N
this_file = fullfile(path_n, file_list{i});
loadfile = load(this_file);
s = struct(loadfile);
h = loadfile.o2a_s ;
jj = h(:,1);
z = datenum(h(:,2),'HH:MM');
h(:,2)=[];
KK = str2double(h);
%finding ths number of rows and columns
[R, C]=size(KK);
% assigning a zero matrix gg of the given size
gg=zeros(1,5);
%% everything is working fine as per needed till here but from here i am facing troubles
j=1;
for ii=1:(R-1)
if z(ii,1)>= 738522.558
while z(ii,1)<= 738522.566
gg=[gg;KK(ii,:)];
end
end
end
iwant{i} = gg ;
end
You already have files names in hand.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!