lundi 24 août 2015

Matlab simple loop not plotting correctly

I'm a Matlab newbie and I'm trying to figure out why my simple loop just won't plot like it should do. The code:

rent_1=1400;
rent_2=1560;
b = zeros(1,10);
month_count = 1:10

y = month_count * rent_1;

if i=1:3
    for 1:3,
        b(1,i)=rent_2(i-0.5040);
    end
elseif i == 4
    b(1,i)=rent_2(i-0.6300);
elseif i == 5
    b(1,i)=rent_2(i-0.7565);
elseif i == 6
    b(1,i)=rent_2(i-0.8825);
elseif i == 7
    b(1,i)=rent_2(i-1.0085);
elseif i == 8
    b(1,i)=rent_2(i-1.1345);
else
    b(1,i)=rent_2(i-1.2605);
end

figure,
plot(month_count,y,i,b(1,i))

Would very much appreciate your feedback. Max Keiser.

Aucun commentaire:

Enregistrer un commentaire