- The "load(files{i_sub})" loads the contents of a file specified by the "files{i_sub}" into the "FileCont" structure.
- The "if(~isfield(FileCont,MatrixName))" condition checks if the field specified by "MatrixName" exists in "FileCont." If it doesn't, an error is thrown, indicating that the field was not found.
- Inside the loop, the condition "if(iscell(MatrixName))" checks if "MatrixName" is a cell array. If it is, "MatrixName" is converted to a string.
- The following "if(is_dyn)" condition checks if "is_dyn" is true. If it is, R is assigned the value of "FileCont.(MatrixName){i_dyn}". Otherwise, R is assigned the value of "FileCont.(MatrixName)". Finally, the code removes rows and columns from R where the corresponding indices in the "brain" variable are equal to 0.
The error regarding 'is_dyn'
2 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am not good at matlab coding. While running a toolbox with my input data I faced errors. To fix my inpu structure I need to understand these lines of the scripts. Do any one have any idea about these code? Why the 'is_dyn' is normally used? Thanks in advance.
FileCont = load (files{i_sub});
if(~isfield(FileCont,MatrixName))
error(['The field "' MatrixName '" has not been found: ' ]);
end
if isfield(FileCont,'is_dyn')
is_dyn = FileCont.is_dyn;
else
is_dyn = 0;
end
if(is_dyn == 1)
n_dyn = size(FileCont.(MatrixName),2);
else
n_dyn = 1;
end
for i_dyn = 1:n_dyn
if(iscell(MatrixName))
MatrixName = MatrixName{:};
end
if(is_dyn)
R = FileCont.(MatrixName){i_dyn};
else
R = FileCont.(MatrixName);
end
del = find(brain==0);
R(del,:) = [];
R(:,del) = [];
0 件のコメント
回答 (1 件)
Maneet Kaur Bagga
2023 年 9 月 22 日
Hi Shukla,
As per my understanding "is_dyn" variable is used to determine whether the input data is considered dynamic or not. The code functions as:
Please refer to the MATLAB Documentation for better understanding of the functions used:
load function
isfield function
iscell
Hope this helps!
Thank You
Maneet Bagga
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!