Multiple outputs of a single function in a single array

P=exp(-0.152+0.859.*6.5-1.803.*log(10+25))
a=linspace(0,3)
for b=(log(a)-log(P))./0.57
fun=@(x) 1./sqrt(2.*pi).*exp(-1/2.*x.^2);
c=integral(fun,-Inf,b)
end
how can I get all outputs of 'c' in a single array? thanks in advance

 Réponse acceptée

P=exp(-0.152+0.859.*6.5-1.803.*log(10+25));
a=linspace(0,3);
for ii = 1:numel(a)
b=(log(a(ii))-log(P))./0.57;
fun=@(x) 1./sqrt(2.*pi).*exp(-1/2.*x.^2);
c(ii)=integral(fun,-Inf,b);
end
disp(c);
Columns 1 through 22 NaN 0.0000 0.0007 0.0064 0.0236 0.0555 0.1014 0.1579 0.2210 0.2870 0.3529 0.4168 0.4771 0.5330 0.5843 0.6308 0.6726 0.7100 0.7434 0.7730 0.7992 0.8223 Columns 23 through 44 0.8428 0.8608 0.8767 0.8907 0.9030 0.9139 0.9235 0.9320 0.9394 0.9460 0.9519 0.9570 0.9616 0.9657 0.9692 0.9724 0.9753 0.9778 0.9800 0.9820 0.9838 0.9854 Columns 45 through 66 0.9869 0.9881 0.9893 0.9903 0.9912 0.9920 0.9928 0.9934 0.9940 0.9946 0.9951 0.9955 0.9959 0.9963 0.9966 0.9969 0.9972 0.9974 0.9976 0.9978 0.9980 0.9982 Columns 67 through 88 0.9983 0.9985 0.9986 0.9987 0.9988 0.9989 0.9990 0.9991 0.9991 0.9992 0.9993 0.9993 0.9994 0.9994 0.9995 0.9995 0.9995 0.9996 0.9996 0.9996 0.9997 0.9997 Columns 89 through 100 0.9997 0.9997 0.9997 0.9998 0.9998 0.9998 0.9998 0.9998 0.9998 0.9998 0.9999 0.9999

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements 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!

Translated by