How to save data in a matrix using looping
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!