how to use an array with function to get another array

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..

Risposte (2)

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?
Try this:
a = lhsnorm(8, 0.05, 2000);
fa = 0.5 * a .^ 2
plot(8*ones(length(fa)), fa, 'b.')
grid on;

Richiesto:

il 10 Feb 2017

Risposto:

il 11 Feb 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by