필터 지우기
필터 지우기

draw empty box by use for loop

조회 수: 1 (최근 30일)
Abu Yamen
Abu Yamen 2016년 12월 4일
댓글: KSSV 2016년 12월 5일
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 ???
  댓글 수: 1
Abu Yamen
Abu Yamen 2016년 12월 4일
can some one correct this cood
function []=drawBox(s,w,h)% s is char
for i= 1:w
fprintf('%s \n',s)
for j=(2,:w-1)&& (:h-1,2)
fprintf('')
end
end

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
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
Abu Yamen
Abu Yamen 2016년 12월 4일
thank you Mr KSSV , appreciated your care still the problem with insert char into fprintf from the function
KSSV
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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by