issue while concatenating the matrix
조회 수: 14 (최근 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
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!