How can I plot my piece-wise function?
Show older comments
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.
Answers (1)
madhan ravi
on 1 Nov 2018
Edited: madhan ravi
on 1 Nov 2018
0 votes
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!