How to display a structure with 2 integer array in a command window?

prompt = 'Enter the Number of Nodes? ';
n = input(prompt);
while (i<=n)
valprompt = 'Enter the value of Node?';
peer(i).value=input(valprompt);
ageprompt = 'Enter the age of Node?';
peer(i).age=input(ageprompt);
i=i+1;
end
I want to display records of structure "peer"

답변 (1개)

Provided the contents are scalars:
vals = [peer.value];
ages = [peer.age];
indx = 1:length(peer);
tab = [indx(:), vals(:), ages(:)];
fprintf('#%3d : value = %g, age = %g\n', tab.');

카테고리

태그

아직 태그를 입력하지 않았습니다.

질문:

2015년 9월 7일

답변:

2015년 9월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by