Graphs set to zero in a two graphs plot

Hello,

When I run this code with non-zero values for Ieq and Req I just get the second function (I2) on the graph. I don't know why the first function (I1) in constantly zero despite the fact that it shouldn't be so. Vd_vec is equal to 0:0.001:Ieq*Req.

    function [ Vd,Id ] = solve_diode_graph( Ieq,Req,Vd_vec )
     V = Vd_vec;
     I1 = Ieq - (V/Req);
     I2 = (10^-12)*(exp(V/0.026)-1); 
     figure();
     plot(V, I1, V, I2);
     legend('Id1', 'Id2')
     Vd = [ ];
     Id = [ ];
    end

2 件のコメント

KSSV
KSSV 2017 年 5 月 12 日
Give the values of Ieq,Req,Vd_vec .
yackhaton
yackhaton 2017 年 5 月 12 日
Ieq = 1, Req =2, Vd_vec = 0:0.001:Ieq*Req

サインインしてコメントする。

回答 (1 件)

KL
KL 2017 年 5 月 12 日
編集済み: KL 2017 年 5 月 12 日

0 投票

if I1 is zero, it comes simply from the line I1 = Ieq - (V/Req);, which are your function inputs.
Nevertheless, according to your equations, I1 should start from Ieq and eventually would become zero in its final timestep since V(end) = Ieq*Req.

3 件のコメント

yackhaton
yackhaton 2017 年 5 月 12 日
On the plot, I2 is shown normally but I1 is just 0. No other value. The strange thing is that if Iplot just I1 alone it takes its real value.
KL
KL 2017 年 5 月 12 日
that's because of the scale, since your Ieq = 1, I1 starts from 1 and meets zero in the end which you cannot see on the graph because I2 starts from 0 and grows exponentially. use the right side y axis with proper limits and you'll see both on the same graph
KL
KL 2017 年 5 月 12 日
or a subplot
figure();
subplot(2,1,1)
plot(V, I1);
title('Id1')
subplot(2,1,2)
plot(V, I2)
title('Id2')

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2017 年 5 月 12 日

コメント済み:

KL
2017 年 5 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by