How to save data in a matrix using looping
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!