X = [struct(jjj).name,' seed ', seedno]; disp(X) is not printing seedno

조회 수: 1 (최근 30일)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 10월 26일
편집: Stephen23 2019년 10월 26일
seedno=data.seed
X = [struct(jjj).name,' seed ', seedno];
disp(X)
any idea why disp(x) is not showing the seedno?
the ouput of disp(x) is:
K_0.045 seed
but it should be:
K_0.045 seed 0
I did not use ; after seedno to print it and is prints correclty:
seedno =
0

채택된 답변

Stephen23
Stephen23 2019년 10월 26일
편집: Stephen23 2019년 10월 26일
X = [struct(jjj).name,' seed ',num2str(seedno)];
disp(X)
Or using low-level commands:
fprintf('%s seed %d\n',struct(jjj).name,seedno)

추가 답변 (1개)

Image Analyst
Image Analyst 2019년 10월 26일
편집: Image Analyst 2019년 10월 26일
Because it's a number not a string. Try
seedno = sprintf('%.2f', data.seed)
X = [struct(jjj).name,' seed ', seedno]
disp(X)
or
seedno = sprintf('%.2f', data.seed)
X = [struct(jjj).name,' seed ', seedno]
fprintf('X = %s\n', X);

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by