how to append a matrix with a nested for loop?

5 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by