Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I write a function for this

1 回表示 (過去 30 日間)
Saman
Saman 2020 年 1 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I finally wrote a simple code to plot two slope lines but the problesm is when I run it the next slope line begins a bit high then the first one. How can I fix that like the graph belowe?
K1 = 3;
K2 = 8;
Idff1 = 20;
endline=100;
XIntersect=50;
IB =[];
ID = [];
for Ibias=0:endline
if Ibias<=XIntersect
Idiff = Idff1 + K1 * Ibias;
ID=[ID, Idiff];
IB = [IB, Ibias];
else
Idiff = K2 * Ibias;
ID=[ID, Idiff];
IB = [IB, Ibias];
end
end
plot(IB, ID);
  1 件のコメント
darova
darova 2020 年 1 月 19 日
Please crop the image

回答 (1 件)

John D'Errico
John D'Errico 2020 年 1 月 18 日
編集済み: John D'Errico 2020 年 1 月 19 日
Use plotregion, found on the file echange.
Note that an if/else clause will be of little value for this purpose. But I suppose you can do anything you want, if you really, desperately need to use if/else.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by