how to append a matrix with a nested for loop?

5 ビュー (過去 30 日間)
nines
nines 2022 年 6 月 29 日
回答済み: NIVEDITA MAJEE 2022 年 6 月 29 日
Hello,
I have a nested for loop where I want to append the matrix for every for loop.
subjs = {'subj1' 'subj2'}
experiments = {'groundtruth' 'change1' 'change2'}
percent_change_matrix = [] %preallocating
percent_change_control_matrix = []
for s = 1:length(subjs)
subj = subjs{s}
for i = 1:length(experiments)
experiment = experiments{i}
data = load(fullfile('text.txt']))
data = data(:,5)
data(:,i)=data
task(:,i) = data(5,5)
baseline(:,i) = data(5,5)
percent_change(:,i) = ((task-baseline)/baseline)*100
end
percent_change_matrix = [percent_change_matrix; percent_change]
end
where I want my output matrix to look as follows:
groundtruth change1 change2
subj 1 0 10 12
subj2 0 10 12
when right now my output looks like this:
0
0
10
12
0
12
Do you have any suggestions?
Thanks

採用された回答

NIVEDITA MAJEE
NIVEDITA MAJEE 2022 年 6 月 29 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by