Meaning of s in string
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Geoff Hayes
2015-2-1
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.
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!