How to plot c(t) vs t with these parameters for various values of v
c(t)=c0-c03*k*(1/cmin-1/cmax)*v*u(t)
where,
u(t)=1, t0
0, t<0
Cmin=10e-9
Cmax=10e-6
C0=100e-9
K=10e6
Thanks in advance

 採用された回答

Yu Jiang
Yu Jiang 2014 年 8 月 12 日
編集済み: Yu Jiang 2014 年 8 月 12 日

0 投票

I would first define a function as follows:
function y = Cfun(t, v)
u = double(t>=0);
Cmin = 10e-9;
Cmax = 10e-6;
C0 = 100e-9;
K = 10e6;
C03 = C0; % I don't know what C03 is, so I set it the same as C0.
y = C0-C03*K*(1/Cmin-1/Cmax)*v*u;
end
Then, create a different MATLAB file with the following code
t = linspace(-10,10,100);
y = [];
for v = [1,5,-1,-5]
y = [y; Cfun(t,v)];
end
plot(t,y(1,:),t,y(2,:),t,y(3,:),t,y(4,:))
legend('v=1', 'v=5', 'v=-1', 'v=-5')
Then, you should be able to see the figure as expected.
-Yu

5 件のコメント

Yu Jiang
Yu Jiang 2014 年 8 月 12 日
編集済み: Yu Jiang 2014 年 8 月 12 日
Did you save the function as a separate MATLAB file with the filename "Cfun.m"?
vetri veeran
vetri veeran 2014 年 8 月 12 日
Finally i got the answer. Thank you. But I need to change the function used in u as step function. can u tell me how it can be achieved.For v, I need to pass different values like v=1,5,-1,-5 and I have to plot all the values of c(t) using different values of v in the same plot. Thanks in advance.
Yu Jiang
Yu Jiang 2014 年 8 月 12 日
Sure.
To change u as a step function, you can simply try
u = double(t>=0);
To plot the data with different v, you can use a for loop. I have revised my original answer and you can directly use the code there.
vetri veeran
vetri veeran 2014 年 8 月 12 日
function y = Cfun(t, v) u = double(t>=0); Cmin = 10e-9; Cmax = 10e-6; C0 = 100e-9; K = 10e6; C03 = C0; % I don't know what C03 is, so I set it the same as C0. y = C0-C03*K*(1/Cmin-1/Cmax)*v*u; end And I typed following given below code in the command window. t = linspace(-10,10,100); y = []; for v = [1,5,-1,-5] y = [y; Cfun(t,v)]; end plot(t,y(1,:),t,y(2,:),t,y(3,:),t,y(4,:)) legend('v=1', 'v=5', 'v=-1', 'v=-5')
Where i am getting an error as Undefined function 'Cfun' for input arguments of type 'double'. I am unable to find the error.can you help me in this regard.
Yu Jiang
Yu Jiang 2014 年 8 月 12 日
Did you put them into to different MATLAB files and execute the script file? It seems to me that you are executing the function file.

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

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2014 年 8 月 12 日

コメント済み:

2014 年 8 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by