how to give range of values to variable

21 views (last 30 days)
please tell me how to code below statments.
for i from 0 to 255
s[i]:=i

Answers (2)

Stephen23
Stephen23 on 25 Feb 2016
Edited: Stephen23 on 25 Feb 2016
Why use slow and ugly loops? This is MATLAB!
s = 0:255;
Note that MATLAB uses one-based indexing, so s(0) is an error.

Walter Roberson
Walter Roberson on 25 Feb 2016
for i = 0 : 255
s(i+1) = i;
end
Or
s = 0 : 255; %no loop needed
  2 Comments
praveena maddamsetty
praveena maddamsetty on 25 Feb 2016
thanks a lot. i am new to matlab if possible please tell how to swap two matrises. deal is not working for swaping s(i) and s(j)

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!