フィルターのクリア

issue while concatenating the matrix

1 回表示 (過去 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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by