Use while loop in equation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to calculate a values c2, c3, c4,..., using the equation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/455284/image.png)
where alpha and beta are the elements of a given vectors of length k. For each q i need to calculate the result. usually Cq will result zero, so i need to find what value of q will be different to zero. I think to do that thing in matlab is using while, but my problem is combine summatory and while in matlab.
for example ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/455289/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/455289/image.png)
in this case the value of k is 2, aplying the equation above for each c2=c3=c4=0 except in c5 which means q=5, by the way values of q start from 2 and above.
Please help me.
4 Kommentare
Antworten (1)
David Hill
am 9 Dez. 2020
C=@(q)sum((1:k).^q.*alpha)/factorial(q)-sum((1:k).^(q-1).*beta)/factorial(q-1);
q=1:100;
c=arrayfun(@(x)C(x),q);
plot(q,c);
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!