Assign a letter to a set of (for example) real numbers?
Show older comments
I am going through a book which is teaching the basics of m files, and one loop they have done is:
for i = 1:m
for j = 1:n
A(i,j) = a/(i + j - 1);
end
end
A
However matlab doesn't understand what " i = 1:n" means, and neither do I. I am guessing it is the set of all real numbers or integers from 1 to n, but maybe because it hasn't been set, matlab doesn't know what it is?
How would I fix this?
Accepted Answer
More Answers (2)
Sean de Wolski
on 17 Oct 2012
m = 5;
n = 6;
a = 10;
A = bsxfun(@(ii,jj)a./(ii + jj - 1),(1:m).',1:n)
Ahmad Rizal
on 11 May 2016
0 votes
m=4 if m>3 a=k; end
Categories
Find more on Loops and Conditional Statements 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!