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!