Need help writing a for loop

5 次查看(过去 30 天)
John
John 2013-4-19
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 个)

Iman Ansari
Iman Ansari 2013-4-19
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

类别

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