Evaluate f(x) for multiple evenly spaced values
Ältere Kommentare anzeigen
How do I evaluate a function f(x) for multiple, evenly spaced values of x between two variables. ie x = exactly 10 evenly spaced numbers between 5 and 20
I'm thinking define an anonymous function so I can evaluate it over a range of values but how to set those values is where I'm lost
Akzeptierte Antwort
Weitere Antworten (1)
Youssef Khmou
am 16 Feb. 2013
hi,
You can set the values using 'linspace' :
x=linspace(5,20,10);
f=@(x) sin(x)
y=feval(f,x);
1 Kommentar
Youssef Khmou
am 16 Feb. 2013
linspace(a,b,n) generates a vector of n points linearly spaced between and including a and b .
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!