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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by