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

카테고리
도움말 센터 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
