Why should we write x(i,1)=cos(theta(1,i) in this format while using the for loop?

2 views (last 30 days)
S Priya
S Priya on 17 Aug 2021
Commented: S Priya on 17 Aug 2021
I have a doubt regarding this way of represention.
for i=1:n+1
x(i,1)=R*cos(Theta_n(1,i)
Why cant we represent it as-
x(i)=R*cos(Theta_n(i))

Accepted Answer

KSSV
KSSV on 17 Aug 2021
Edited: KSSV on 17 Aug 2021
x = zeros(n+1,1) ;
for i=1:n+1
x(i)=R*cos(Theta_n(i)
You can very much write like you shown. But keep in mind that the variables should be vectors.
  4 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by