필터 지우기
필터 지우기

Problem with fprintf command

조회 수: 2 (최근 30일)
Aftab Ahmed Khan
Aftab Ahmed Khan 2015년 2월 9일
댓글: Aftab Ahmed Khan 2015년 2월 9일
hello everyone, I have this set of schemes which i want to print. The way i am doing is like this, The "pno" control for me the active protocol that i want to display. Any help. Thank you.
protocol={'HighestSINR_closest' 'RandomResource' 'FirstAvailable'}; % Set of protocols
pno=3; %protocol number
fprintf('Current Scheme, %s',protocol(pno));

채택된 답변

Guillaume
Guillaume 2015년 2월 9일
편집: Guillaume 2015년 2월 9일
You need to learn and understand cell array indexing.
cellarray(indices)
returns a cell array made of the cells in indices,e.g:
c1 = c2([1 3 5]) %return a cell array made of cells 1, 3 and 5 of c2
c1 = c2(3) %return a cell array made of 1 cell: cell 3 of c2
whereas,
cellarray{index}
returns the content of the cell at index.
You want the content of the cell, so use curly braces:
fprintf('Current Scheme, %s\n',protocol{pno}); %you may also want a '\n' in your string

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by