Trying to print a vector.

조회 수: 15 (최근 30일)
Manuel López
Manuel López 2020년 11월 21일
댓글: Manuel López 2020년 11월 21일
Hi everyone. I'm trying to print a vector as follows:
fprintf(doc,'k0 = [%.3f %.3f %.3f %.3f].',k0);
where k0 is a 4-dimensional vector with numerical components and doc is a .txt document. Nonetheless, I would want to print any other vector k0 without making explicit reference to its dimension. I mean, I would like to change de dimension of k0 and not changing the code. Can someone help me?
Thanks!

채택된 답변

dpb
dpb 2020년 11월 21일
fprintf(doc,['k0 = ' repmat('%.3f ',1,numel(k0)) '.'],k0);

추가 답변 (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