Write matrix or array without overwriting
12 views (last 30 days)
Show older comments
Dion Theunissen on 18 Feb 2021
Commented: Walter Roberson on 18 Feb 2021
I am getting a parameter called 'test' in a for loop. I want to write it to a matrix or array without overwriting. Each loop has a different dimension so that makes it a bit complicated.
I need on line h 'r' values of test, line h the new 'r' values of test and so on. So test needs to come in row h, column r.
for h = 3:10
A = 
for r = 1:g
for m = 1:numbcenterlines
percentage(m) = sum(distance>0 & distance <1) / numel(distance)*100;
test = max(percentage,,'all');
A(r,h) = [A;test] %this part doesn't work well so my question is how to fix this part and get an array here with all the test values without overwriting
Stephen23 on 18 Feb 2021
You are mixing up two different approaches to adding data in a loop: concatenation and indexing. Just pick one, e.g.:
A = [A;test];
More Answers (0)
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!