draw empty box by use for loop
2 ビュー (過去 30 日間)
古いコメントを表示
if some one can help to correct this code we need function to read ch like * and width ,length from user and draw the box for 1:h disp('*') for 1:w 2:end-1 ,2:end-1 = char end end
i could not write correct code ???
採用された回答
KSSV
2016 年 12 月 4 日
function []=drawBox(s,w,h)% s is char
for i= 1:w
for j=1:h
if i==1||i==w||j=1||j==h
fprintf('%s \n',s) ;
else
fprintf('');
end
end
end
2 件のコメント
KSSV
2016 年 12 月 5 日
s = '*' ; h = 10 ; w = 10 ;
% iwant = num2str(zeros(h,w)) ;
for i= 1:w
for j=1:h
if i==1||i==w||j==1||j==h
% fprintf('%s \n',s) ;
iwant(i,j) = s ;
else
% fprintf('');
iwant(i,j) = ' ' ;
end
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!