如何在循环中更改'StartRow'和'EndRow'的值?
for k = 1:11
filename = 'file.txt';
...
startRow = 1422; %1564, 1706, 1848, 1990, 2132, 2274, 2416, 2558, 2700, 2842
endRow = 1562; %1704, 1846, 1988, 2130, 2272, 2414, 2556, 2698, 2840, 2982
...
f=figure;
plot(...);
saveas(f,sprintf('fig%d.png',k));
端
答案 0 :(得分:1)
您可以将startRow
和endRow
的所有值存储在for循环之前的列表中,然后遍历列表以更改循环内这些变量的值。
startRowList = [1422, 1564, 1706, 1848, 1990, 2132, 2274, 2416, 2558, 2700, 2842];
endRowList = [1562, 1704, 1846, 1988, 2130, 2272, 2414, 2556, 2698, 2840, 2982];
for k = 1:11
filename = 'file.txt';
...
startRow = startRowList(k);
endRow = endRowList(k);
...
f=figure;
plot(...);
saveas(f,sprintf('fig%d.png',k));
end
答案 1 :(得分:1)
将startRow和endRow保持在循环之外,并使用循环索引在循环内调用它们。
startRow = [1422 1564, 1706, 1848, 1990, 2132, 2274, 2416, 2558, 2700, 2842] ;
endRow = [1562 1704, 1846, 1988, 2130, 2272, 2414, 2556, 2698, 2840, 2982];
n = length(startRow) ;
for k = 1:n
filename = 'file.txt';
thestart = startRow(k) ;
theend = endRow(k) ;
...
...
f=figure;
plot(...);
saveas(f,sprintf('fig%d.png',k));
end
答案 2 :(得分:1)
WHERE `company_id` = 1
AND (
`firstname` LIKE '%?%'
OR `lastname` LIKE '%?%'
)