for loop in equation

2 次查看(过去 30 天)
Yo Volks, i am new in programming. i want to apply for loop in the equation 'phi_acc' which goes from '1 to nsamples' and after that want to put it in the phi equation.
phi_sync = rand(1,nsamples);
phi_acc = rand(1,nsamples);
phi = phi_sync(nsamples) + Phi_acc(nsamples);

采纳的回答

Star Strider
Star Strider 2015-7-22
The code you posted will take the last values of ‘phi_sync’ and ‘phi_acc’ to calculate ‘phi’. (Also, MATLAB is case-sensitive, so ‘Phi_acc’ is a different variable from ‘phi_acc’, and will throw an error if you haven’t defined it.)
If you want to add the two vectors of the same size, just use:
phi = phi_sync + phi_acc;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by