how to define printf comand in matlab.

조회 수: 6 (최근 30일)
shrisha tv
shrisha tv 2018년 7월 19일
댓글: shrisha tv 2018년 7월 19일
hello. I got result in a column matrix 4*1 like (1 0 0 0) or (0 1 0 0) etc. Now I have to provide output means printf as car for first case (that is (1 0 0 0 )), bike for second case. In this way I have 4 cases. how to write program for this please some one help me. thank you.

채택된 답변

KSSV
KSSV 2018년 7월 19일
편집: KSSV 2018년 7월 19일
k = [1 0 0 0] ;
fprintf('%s %f %f %f %f\n','car',k') ;
If you want it in file:
c = [1 0 0 0] ;
b = [0 0 1 0] ;
fid = fopen('myfile.txt','w') ;
fprintf(fid,'%s %f %f %f %f\n','car',k') ;
fprintf(fid,'%s %f %f %f %f\n','bike',b') ;
fclose(fid) ;
  댓글 수: 6
shrisha tv
shrisha tv 2018년 7월 19일
nothing printed sir. I am not able to debug. please explain that code then I find the solution.
shrisha tv
shrisha tv 2018년 7월 19일
Ya i got answer, thank you very much sir.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by