Want to run the code for n values of X0, tried using for loop but didn,t get desired output.how to run for n values of X0?
Afficher commentaires plus anciens
if true
X = [ 0, 15 30 45 ];
Y = [50, 8.5, 2, 0.5];
X0 = 0;
n = 100;
f = 0.1;
x = linspace(min(X),max(X),n);
y = interp1(X,Y,x,'spline');
xt = X0+(0.1*(max(X)-min(X))*[-1 0 1]);
m = diff(y)./diff(x);
m = [m, m(end)];
k = min([find(x >= X0,1,'first'), length(x)]);
yt = y(k) + m(k)*(0.1*(max(X)-min(X))*[-1 0 1]);
plot(X,Y,'ro', x,y,'-b',xt,yt,'--g');
% code
end
3 commentaires
Geoff Hayes
le 11 Juin 2014
Please format the above code so that it is readable. Highlight the code portions (not your text that asks a question or states the error) and press the {} Code button.
Geoff Hayes
le 11 Juin 2014
What do you want the n values for X0 to be? The first is zero, the second one is… What should this sequence be?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements 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!