Borrar filtros
Borrar filtros

for loop in equation

2 visualizaciones (últimos 30 días)
Kutru biladi
Kutru biladi el 22 de Jul. de 2015
Respondida: Star Strider el 22 de Jul. de 2015
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);

Respuesta aceptada

Star Strider
Star Strider el 22 de Jul. de 2015
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;

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by