calling a variable in another function
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
WILLBES BANDA
am 30 Mai 2020
Beantwortet: Image Analyst
am 30 Mai 2020
Hi, i have 2 functions where i calculated a variable in function 1, now i want to use the variable in function 2 but it says variable not recognised. In my case i calculated TableFiles(which has names of excel spreadsheets) in function 1 and i want to open the files in function 2 using read cell. Please help
function [LookupTableFiles]=getaerotablelisting( FilePrefix, DirectoryName , filetype )
FileList = dir('DynamicData*.xlsx')
TableFiles = {};
for LenFlLst = 1:numel(FileList)
TableFiles = {FileList.name}
end
end
function [Cols,StructOut]=getindepvars( CurrentSheet )
for LenTables = 1:size(CurrentSheet)
CurrentSheet = readcell(TableFiles);
Raw = CurrentSheet;
if ischar(Raw{1,1}) == 1
IndepVariablename = Raw(1,1);
Range = Raw(2:end,1);
StructOut.(Raw{1,1}) = [Range{:}];
a = size(Raw);
Cols = a(:,2);
end
end
end
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 30 Mai 2020
Pass it in when you call the second function:
function LookupTableFiles = getaerotablelisting( FilePrefix, DirectoryName , filetype )
FileList = dir('DynamicData*.xlsx')
LookupTableFiles = {FileList.name}
end
function [Cols,StructOut]=getindepvars( CurrentSheet, LookupTableFiles )
for LenTables = 1:size(CurrentSheet)
CurrentSheet = LookupTableFiles{LenTables};
Raw = CurrentSheet;
if ischar(Raw{1,1}) == 1
IndepVariablename = Raw(1,1);
Range = Raw(2:end,1);
StructOut.(Raw{1,1}) = [Range{:}];
a = size(Raw);
Cols = a(:,2);
end
end
end
Lots of other problems with that code but I don't have time now to fix them all....sorry
0 Kommentare
Weitere Antworten (1)
Stephan
am 30 Mai 2020
function [LookupTableFiles]=getaerotablelisting( FilePrefix, DirectoryName , filetype )
FileList = dir('DynamicData*.xlsx')
TableFiles = {};
for LenFlLst = 1:numel(FileList)
TableFiles = {FileList.name}
end
function [Cols,StructOut]=getindepvars( CurrentSheet )
for LenTables = 1:size(CurrentSheet)
CurrentSheet = readcell(TableFiles);
Raw = CurrentSheet;
if ischar(Raw{1,1}) == 1
IndepVariablename = Raw(1,1);
Range = Raw(2:end,1);
StructOut.(Raw{1,1}) = [Range{:}];
a = size(Raw);
Cols = a(:,2);
end
end
end
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!