matrix - Using fprintf to print on several lines in Matlab -


question: write procedure called print7 print integer numbers within range 0:100 divisible 7. ten numbers printed on 1 output line. hence write program invokes procedure.

this did

 file = fopen('print7.dat','r');   x = 1:100   x=[1:100]    if mod(x,7) == 0;     print7 = [x]  end end  fprintf('print7 %d\n', print7) 

now it's output becomes number 98 - understand largest number under 100 divisible 7. want 10xn matrix-like result.

what do?

what doing stores result in variable , overwrites variable in each iteration. print directly instead this:

c=0;  x=[1:100]    if mod(x,7) == 0       fprintf('%3d',x)       c=c+1;       if mod(c,10) ==0         fprintf('\n')       end    end end 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -