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

답변 (2개)

James Tursa
James Tursa 2017년 2월 10일
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
Image Analyst 2017년 2월 11일
Try this:
a = lhsnorm(8, 0.05, 2000);
fa = 0.5 * a .^ 2
plot(8*ones(length(fa)), fa, 'b.')
grid on;

카테고리

질문:

2017년 2월 10일

답변:

2017년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by