南京邮电大学吧 关注:332,676贴子:11,265,572
  • 15回复贴,共1

求助,matlab问题求助!!!

只看楼主收藏回复

自己毕设的程序,蛮简单的(如果我现在没写错的话),二分搜索,然而在仿真结果时感觉图像不太对,想求教哪个地方出了问题。


1楼2015-05-19 20:59回复
    下面为matlab程序 %后的数据为运行程序时需要输入的
    %eta=1e-10 pev_max=0.003 MW b=0.01 MW pnev_i_t=zeros(24,24)
    function [pev_i_t]=qwe_c(eta,pev_max,b,pnev_i_t)
    M=24;
    T=24;
    pev_i_t=zeros(M,T);
    pnev_t=zeros(1,T);
    for i=1:1:M
    for t=1:1:T
    pnev_t(1,t)=sum(pnev_i_t(1:M,t));
    pev_i_t(i,:)=qwe_d(eta,pev_max,b,pnev_t(1,:));
    pnev_t=pnev_t+pev_i_t(t);
    end
    end
    figure;
    T=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
    pev_1_t(1,t)=pev_i_t(1,t);
    pev_2_t(1,t)=pev_i_t(2,t);
    plot(T,pev_1_t,'-',T,pev_2_t,':');
    title('phev');
    xlabel('time');
    ylabel('power');
    legend('pev_1_t','pev_2_t');
    end
    function [pev_t]=qwe_d(eta,pev_max,b,pnev_t)
    T=24;
    pev_t=zeros(1,T);
    alpha_min=min(pnev_t);
    alpha_max=max(pnev_t)+pev_max;
    while alpha_max-alpha_min>eta
    alpha=(alpha_max+alpha_min)/2;
    for t=1:1:T
    pev_t(t)=qwe_a(alpha-pnev_t(t),pev_max);
    end
    if sum(pev_t)>b
    alpha_max=alpha;
    else
    if sum(pev_t)<b
    alpha_min=alpha;
    end
    end
    end
    end
    function [re]=qwe_a(x_k,pev_max)
    if x_k>pev_max
    re=pev_max;
    else
    if 0<=x_k&&x_k<=pev_max
    re=x_k;
    else if x_k<0
    re=0;
    end
    end
    end
    end


    2楼2015-05-19 20:59
    回复
      2026-02-08 17:42:46
      广告
      不感兴趣
      开通SVIP免广告

      这张图是我输出的结果pev_i_t


      这两张图是我程序运行后生成的图,意图表示pev_1_t和pev_2_t两个在1到T时间内的取值,根据前面一张图中的数据显示,我觉得生成的图像不应该是这样的。
      希望各位大大能帮忙解决这个问题,十分感谢!!!


      3楼2015-05-19 21:00
      回复
        然而还没有人回。。。


        来自Android客户端4楼2015-05-19 21:11
        回复


          5楼2015-05-19 21:12
          收起回复
            不会


            IP属地:广东来自Android客户端6楼2015-05-19 21:14
            收起回复
              并不会


              来自iPhone客户端7楼2015-05-19 21:23
              收起回复
                同学进错吧了


                IP属地:中国香港来自iPhone客户端8楼2015-05-19 23:54
                收起回复
                  2026-02-08 17:36:46
                  广告
                  不感兴趣
                  开通SVIP免广告
                  不会 帮顶


                  来自iPhone客户端9楼2015-05-20 07:57
                  收起回复