Meaning of s in string
4 views (last 30 days)
Show older comments
Please help guys, thanks. My struggles involves around the question:
n=10;
fact=1;s
for k=1:n
fact=k*fact;
factorials(k,:)=[k fact];
end
factorials
I am using octave GNU. What does the "s" stand for in "fact=1;s". It makes no sense to me whatsoever. Also whats the difference in Matlab with the bracket () and [] as in "factorials(k,:)=[k fact]"
0 Comments
Accepted Answer
Geoff Hayes
on 1 Feb 2015
S - I think that the s is a mistake and should not be there so just remove it. (It could have been a typo by the author of the code).
As for the use of (), in the context above the open brackets are used to access elements of the matrix factorials. In this case, on each iteration of the loop, we set all elements of the kth row to
[k fact]
which is just a two element array of k and fact. Here, the square brackets [] are used to concatenate the two scalar values into a 1x2 array.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!