how to use an array with function to get another array
Mostra commenti meno recenti
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)
James Tursa
il 10 Feb 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
il 11 Feb 2017
Try this:
a = lhsnorm(8, 0.05, 2000);
fa = 0.5 * a .^ 2
plot(8*ones(length(fa)), fa, 'b.')
grid on;

Categorie
Scopri di più su Lighting, Transparency, and Shading in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
