就像下圖這樣把所有素數變成紅色


figure;
axis([1 11 1 11]);
axis ij;
for irow = 1:10
for icol = 1:10
num = (irow-1)*10+icol;
if isprime(num)
text(icol + 0.3, irow + 0.5, num2str(num), Color, red);
else
text(icol + 0.3, irow + 0.5, num2str(num));
end
end
end
axis off;

歡迎關注我的MATLAB專欄

MATLAB?

zhuanlan.zhihu.com圖標


推薦閱讀:
相关文章