首页 > 编程学习 > 代码练习

代码练习

发布时间:2022/9/18 4:52:47
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

  

Copyright © 2010-2022 mfbz.cn 版权所有 |关于我们| 联系方式|豫ICP备15888888号