how to use an array with function to get another array
Afficher commentaires plus anciens
I have an array, a = lhsnorm(8,0.05,2000); the function is F(x)=0.5*x.^2; Can I use the array a as variable with the function to get another array f(a)? Then I will plot this array as dot matrix. And the abscissa for these dot matrix is not X but a constant, e.g 8, the ordinate is f(a), can anybody help me? I am looking forward to your reply, thanks..
Réponses (2)
James Tursa
le 10 Fév 2017
Well, you can certainly do the first part:
a = lhsnorm(8,0.05,2000);
F = @(x)0.5*x.^2
fa = F(a);
For plotting, I am not sure what you want. Apparently not this:
plot(a,fa)
Can you be more specific?
Image Analyst
le 11 Fév 2017
Try this:
a = lhsnorm(8, 0.05, 2000);
fa = 0.5 * a .^ 2
plot(8*ones(length(fa)), fa, 'b.')
grid on;

Catégories
En savoir plus sur Lighting, Transparency, and Shading 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!
