Need help writing a for loop

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 Kommentar

John
John am 19 Apr. 2013
Can I just plug it in as I have written above?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Iman Ansari
Iman Ansari am 19 Apr. 2013

0 Stimmen

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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 19 Apr. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by