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?
Afficher commentaires plus anciens
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)
Réponse acceptée
Plus de réponses (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,'-*')
Catégories
En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
