For loop while saving data in matrix
Show older comments
Good day i'm quite new to mathlab and i'm having a bit of problems. I'm not new to programming but i am new to matlab and for some reason i can't get past this problem. Any help would be greatly appreciated. I am trying to have a for loop which starts at 1 and decriments by 0.01 and stops at 0.0001 in this loop i need values to be stored in an array for both variable, Tind and s. S changes in the loop and would be the same values as the loop itself which is from 1 to 0.0001 with a decriment of 0.01.. After storing both of these values in a matrix i would then plot them. Below is my code. I'm a bit new so my apologies if my code is a bit nooby.
for k=[1:-0.01:0.0001]
s(k)= k
ws=1800*((2*pi)/60)
Vth=255.2
R2=.332
Rth=0.59
Xth=1.106
X2=0.464
a=1/ws
b=(3*Vth.^2*(R2/s))
c=((Rth+(R2/s)).^2+(Xth+X2).^2)
Tind(k)=a*(b/c)
end
Plot(Tind,s)
I get the following error
Attempted to access s(0.99); index must be a positive integer or logical.
Error in test (line 2) s(k)= k
Any help would be greatly appreciated. Thank You.
Accepted Answer
More Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!