MATLAB: Draw empty box by use for loop if some one can help 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 ??? Best Answer 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 Related SolutionsMATLAB: Replace matrix elements by the difference with the highest alternative in the same row clc; clear all; A = [1 6 13 3 9 2 7 11 20] ;iwant = zeros(size(A)) ;for i = 1:size(A,1) for j = 1:size(A,2) iwant(i,j) = A(i,j)-max(setdiff(A(i,:),A(i,j))) ; endendiwant MATLAB: How to fill matrix in a specific way A = [11 44 1; 11 33 -1; 22 11 1; 22 44 1; 22 33 1;33 44 1; 33 22 -1; 44 11 1 ; 44 22 -1; 44 33 1] ;c1 = A(:,1) ; c2 = A(:,2) ;c1 = unique(c1) ;c2 = unique(c2) ;iwant = zeros(length(c1)+1,length(c2)+1) ;iwant(2:end,1) = c1 ;iwant(1,2:end) = c2 ;for i = 2:size(iwant,1) for j = 2:size(iwant,2) [val,idx] = ismember([iwant(1,i) iwant(j,1)],A(:,1:2),'rows') ; if idx~=0 iwant(i,j) = A(idx,3) ; end endend Related QuestionCalculation of a double sumHow can i fix this error?why is the function unused even though its written in the same manner as the preceding function that workWrite a function drawBox which draws boxes on the screen
Best Answer