issue while concatenating the matrix

조회 수: 14 (최근 30일)
Arvind Gauns
Arvind Gauns 2022년 6월 30일
댓글: KSSV 2022년 6월 30일
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
Stephen23
Stephen23 2022년 6월 30일
if isnumeric(file_list)
return
end
file_list = cellstr(file_list);
Arvind Gauns
Arvind Gauns 2022년 6월 30일
thanks for the response.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2022년 6월 30일
편집: KSSV 2022년 6월 30일
[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
Arvind Gauns
Arvind Gauns 2022년 6월 30일
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.559
if z(ii,1)<= 738522.565
gg=[gg;KK(ii,:)];
end
end
end
iwant{i} = gg ;
end
with a little modification, it worked.
Thanks.
KSSV
KSSV 2022년 6월 30일
Thanks is accepting/ voting the answer... :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by