How can I plot my piece-wise function?

1 回表示 (過去 30 日間)
Olivia
Olivia 2018 年 11 月 1 日
編集済み: madhan ravi 2018 年 11 月 1 日
I have 4 vectors for my variables:
a(i) = [0.0385, 0.1379, 1, 0.1379];
b(i) = [0.1961, 1.8289, -1.7164, -0.2033];
c(i) = [12.9973, 3.0504, -6.8966, 3.0504];
d(i) = [-13.2626, -13.2626, 13.2626, 13.2626];
I also have the vector: x(i) = [-1, -0.5, 0, 0.5]
These are going to be used in this equation to form 4 separate equations:
f(x) = ai + bi(x-xi) + ci(x-xi)^2 + di(x-xi)^3
I need to plot the four equations like:
f1(x) = ..... from x = -1 to -.5
f2(x) = ..... from x = -.5 to 0
f3(x) = ..... from x = 0 to .5
f4(x) = ..... from x = .5 to 1
I am at a loss for how I can even begin to plot something like this in MATLAB. I've been playing around with for loops, but I am having a lot of difficulty defining the x variable that is not the x(i) variable.

回答 (1 件)

madhan ravi
madhan ravi 2018 年 11 月 1 日
編集済み: madhan ravi 2018 年 11 月 1 日

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by