date1 = ["高钾风化","高钾未风化","铅钡风化","铅钡未风化"]; val = [1,2,5,10,20,30,50,100]; for i=1:length(val) date2 = val(i); dir = "rand" + date2; mkdir(dir); for t=1:4 date3 = date1(t) + ".xlsx"; %target = fullfile copyfile(date3,dir); date3 = dir + "/" + date3; A = xlsread(date3); [n,m] = size(A); R = rand(n,m-3).*0.01*date2 + 1-date2*0.005; A(:,3:m-1) = A(:,3:m-1).*R; A(:,m) = sum(A(:,3:m-1),2); xlswrite(date3,A,"E2:U" + (n+1)); end end
date1 = ["高钾风化","高钾未风化","铅钡风化","铅钡未风化"]; val = [1,2,5,10,20,30,50,100]; for i=1:length(val) date2 = val(i); dir = "rand" + date2; mkdir(dir); for t=1:4 date3 = date1(t) + ".xlsx"; %target = fullfile copyfile(date3,dir); date3 = dir + "/" + date3; A = xlsread(date3); [n,m] = size(A); R = rand(n,m-3).*0.01*date2 + 1-date2*0.005; A(:,3:m-1) = A(:,3:m-1).*R; A(:,m) = sum(A(:,3:m-1),2); xlswrite(date3,A,"E2:U" + (n+1)); end end
标签:rand,date3,date2,val,代码,练习,风化,dir From: https://www.cnblogs.com/1963432477zxl/p/16704129.html