How can I divide a given range of three values into equal subparts like abc=[initial_values, mid_value, last_value] and expand the range into a total of 9 or 12 values?
Show older comments
Hello,
I want to display the given values in a graph. However, the result contains only three values which does not look good on the graph. I want to display multiple points on the graph.
x = [80 160 240];
y = [0.0623671622299242 0.109342051940389 0.158597892409503];
plot(x,y);
I want the graph to have the original values as well as values in between the given values i.e. x = 80, 100, 120, 140, 160, 180, 200, 220, 240... I want to do it through code not manually. Can anyone help?
(PS: I'm a newbie)
1 Comment
Sibghat
on 7 Mar 2022
Accepted Answer
More Answers (1)
The MATLAB approach is to use INTERP1, because what you ask about is exactly what interpolation is for:
x = [80,160,240];
y = [0.0623671622299242,0.109342051940389,0.158597892409503];
xq = unique([x(1):20:x(end),x]);
yq = interp1(x,y,xq);
plot(xq,yq,'-*')
Categories
Find more on Language Fundamentals 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!