HOW TO WRITE THE FOLLOWING FUNCTION IN A MATLAB PROGRAM ? ALSO TELL THE WAY TO PLOT F(X)

2 ビュー (過去 30 日間)
RAJKUMAR
RAJKUMAR 2014 年 7 月 16 日
コメント済み: Sara 2014 年 7 月 16 日
F(X) =X , in (0,1) and F(X) =(X/2)+5 in (1,2)
  1 件のコメント
James Tursa
James Tursa 2014 年 7 月 16 日
What have you done so far? Have you written any code? Even an outline?

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

回答 (1 件)

Sara
Sara 2014 年 7 月 16 日
x = linspace(1e-6,2-1e-6,100);
f1 = x(x>0&x<1);
f2 = x(x>1&x<2)/2+5;
plot(x,[f1,f2])
  2 件のコメント
Jasmine
Jasmine 2014 年 7 月 16 日
Out of interest, what happens using this code if x is exactly 1?
Sara
Sara 2014 年 7 月 16 日
I'll crash since x and [f1,f2] will be of different sizes. That's a cheap and easy solution to plot the function, not meant to represent all the occurrences. Can be modified as:
plot(x(x>0&x<2&x~=1),[f1,f2])

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

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by