在for Matlab中打印多个图表的问题

时间:2019-07-16 15:51:03

标签: matlab for-loop graph

根据W_esc_eV的值,我想将(partices)划分为多个部分,对于每个划分图,Rsm时间找到该图的拟合度,并为每个拟合度的系数制成表格。但是代码仅打印出来第一张图和拟合图,有人可以告诉我我做错了吗?

    rd1start=1;   start=1;
   rd1end=1000;    ending=1000;
   end2=100;
    ntM=1000; 
    nP=1000;
   rmsd=rand(nP,ntM);
   rmsd_=rmsd;
  split=(10000*10^3); %used to split the particles into clases

   Rsm=zeros(1000,ntM); % create the matrix we need for the plot

    for jN=1:1000
      rmsd=rmsd_;     %rmsd_ matrix  is exactly the same as rmsd
        for i=1:nP
             if W_esc_eV(i)<=split*(jN-1) || W_esc_eV(i)>= split*(jN)

             rmsd(i,:)=0;
              end
         end
             for j=1:1000


                p1(jN,j)=nnz(rmsd(jN,:,j));  % non zero elements ,in order 
              to divide
                 Rsm(jN,j)=sum(rmsd(jN,:,j))/p1(jN,j); % the matrix i need 
              to plot

              end

       end

         new=ones(end2,ntM);
          tM1=new.*tM;

        for jN=1:end2
            figure(5)


        fitResults1=         %create the fit
       polyfit(log10(tM1(jN,start:ending)),log10(Rsm(jN,start:ending)),1);
      pol1=polyval(fitResults1(jN),log10(tM1(jN,start:ending)));
      a1=fitResults1(1);
      b1=fitResults1(2);
      fitRsm=tM1(jN,start:ending).^(a1)*10^(b1);
      polyfit_str = ['fitRsm = ' num2str (a1) ' *x + ' num2str(b1)];
      text(1.2,10^19,polyfit_str,'FontSize', 10, 'Color', 'g', 
         'FontWeight', 'bold');

       loglog((tM1(jN,rd1start:rd1end)),(Rsm(jN,rd1start:rd1end)),'r-') 
     %what i want to plot
    hold on
      loglog(tM1(jN,start:ending),(fitRsm(jN,start:ending))) % also add 
        the fit in the plot


           end
       hold off

0 个答案:

没有答案