How to save data in a matrix using looping
Show older comments
Hello,
I have a problem where I need to read data from several text files, get maximum absolute values from 4 different columns and then save it in the first column of a new matrix followed by repetaetion of same process for next value of Kc and saving the data in next column. The issue is that the resulting matrix is just showing the results of final try and that too in 3rd column of SH with first 2 columns having zeros.
Thanks,
nn = 0;
for Kc = [31528 21018]
Shear = zeros(4,1);
temp1 = readmatrix(strcat('.\Data\sf',num2str(Kc),'.txt'),'delimiter',' '); % Read .txt file
Shear(1,1) = max(abs(temp1(:,2)));
Shear(2,1) = max(abs(temp1(:,8)));
Shear(3,1) = max(abs(temp1(:,14)));
Shear(4,1) = max(abs(temp1(:,20)));
SH = zeros(4,2);
SH(:,nn+1) = Shear(:,1);
end
Accepted Answer
More Answers (0)
Categories
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!