How can i find the number of lines

12 views (last 30 days)
Thar
Thar on 13 Dec 2014
Answered: Guillaume on 13 Dec 2014
Hi all!!
I have the script:
for h=1:2004
for j=1:numberOfLines; (problem)
K(j,h)=T(j,h)/N(j,1);
end
end
I don't know the number of lines and i need to put in the loop. What can i do?
Thank you!

Accepted Answer

Guillaume
Guillaume on 13 Dec 2014
If numberOfLines is supposed to be the numbers of rows in K, T, and N, then have a look at the size function:
numberOfLines = size(T, 1);
However, don't use loops for this sort of calculations. It's simply:
K = bsxfun(@rdivide, T, N);

More Answers (0)

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!