% Problem : First'for' loop will run four time. Each time z(n+1) will have % four different values.I want to plot this z(n+1) values for different % value of y. ( Y range can be 0.63095:3.98107) for y=0.63095:3.98107 B=0.5.*(1-sqrt(y./(1+y)));
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Question relating to plotting
2 Comments
Geoff Hayes
on 13 Jul 2018
naina - please show your code so that we can understand what the first for loop is. Are you trying to plot something on each iteration of the loop? Is there a second for loop?
naina gupta
on 13 Jul 2018
Edited: Geoff Hayes
on 13 Jul 2018
Answers (1)
Geoff Hayes
on 13 Jul 2018
naina - I suspect that you want to make z a 4x33 matrix
z = zeros(4,33);
k = 1;
for y=0.63095:3.98107
B=0.5.*(1-sqrt(y./(1+y)));
P=[ 0 0 0 0 0 0.0020 0.0134 0.0523 0.1498 0.3479 0.6496 0.9156 0.9968 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1];
z(k,1)=0;
for n=1:32
z(k,n+1)=((factorial(32))./(factorial(n).*(factorial(32-n))).*(B.^(n)).*((1-B).^(32-n)).*(P(n)));
z(k,n+1)=z(k,n)+z(k,n+1);
end
k = k + 1;
end
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!