Need help writing a for loop

5 visualizaciones (últimos 30 días)
John
John el 19 de Abr. de 2013
I am having trouble figuring out how to use a for loop , I have variable that I have assigned values.
period T = 1 ms
voltage amplitude Vm = 1 V
t = linspace(0, T, 1001)
I need to create a for loop that will give me a vector v which is based on:
v(t) = (Vm/T)*t
Can anyone help me out?
  1 comentario
John
John el 19 de Abr. de 2013
Can I just plug it in as I have written above?

Iniciar sesión para comentar.

Respuestas (1)

Iman Ansari
Iman Ansari el 19 de Abr. de 2013
Hi. You don't need for loop to doing this:
T = 1;
Vm = 1;
t = linspace(0, T, 1001)
v = (Vm/T)*t
with for:
for i=1:1001
v(i)=(Vm/T)*t(i);
end

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by