Clear Filters
Clear Filters

How do a write a loop code in MATLAB?

5 views (last 30 days)
N/A
N/A on 26 Nov 2018
Edited: Stephen23 on 26 Nov 2018
How do I impliment a "for loop" into this code?
for r = 1 : numPlotsR
for c = 1 : numPlotsC
subplot(numPlotsR, numPlotsC, plotIndex);
rgbBlock = ca{r,c}; imshow(rgbBlock);
[rowsB, columnsB, numberOfColorBandsB] = size(rgbBlock);
caption = sprintf('Block #%d of %d\n%d rows by %d columns', ...
plotIndex, numPlotsR*numPlotsC, rowsB, columnsB);
title(caption); drawnow;
xlswrite(NewID,rgbBlock);
plotIndex = plotIndex + 1;
img1=rgbBlock;
imshow(img1)
  1 Comment
Bob Thompson
Bob Thompson on 26 Nov 2018
I don't understand your question. You have two for loops set up already for the code. What do you mean by, "impliment a 'for loop' into this code?"

Sign in to comment.

Accepted Answer

Jim Riggs
Jim Riggs on 26 Nov 2018
Edited: Jim Riggs on 26 Nov 2018
A "for" loop requires an "end" statement:
for r=1:numPlotsR
for c=1:numPlotsC
...
...
end
end

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!