I'm trying to create this matrix:
However, I'm gettng this:
This is my code:
I'm sure it has something to do with the format operators but I'm not sure what it is.
Thank you for your help in advance

댓글 수: 4

James Tursa
James Tursa 2021년 6월 18일
Will you always know how many decimal digits you want printed? Or will this depend on the values in Node?
Mo A
Mo A 2021년 6월 18일
No, this will depend on the values within Node.
Stephen23
Stephen23 2021년 6월 18일
"This is my code:"
No, that is an image of some code: we cannot run code in an image, nor can we use that matrix.
Please provide code as text.
Sorry, here is the code:
Node = [1, 0., 0., 0.;
2,100., 0., 0.;
3,200., 0., 0.;
4,33.3333321,0.,0.;
5,66.6666641, 0., 0.;
6,133.333328,0.,0.;
7,166.666672,0.,0]
fprintf(fid, '%d,%g,%g, %g \n' , Node');

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

 채택된 답변

Stephen23
Stephen23 2021년 6월 18일

0 개 추천

Node = [1,0,0,0;2,100,0,0;3,200,0,0;4,33.3333321,0,0;5,66.6666641,0,0;6,133.333328,0,0;7,166.666672,0,0]
Node = 7×4
1.0000 0 0 0 2.0000 100.0000 0 0 3.0000 200.0000 0 0 4.0000 33.3333 0 0 5.0000 66.6667 0 0 6.0000 133.3333 0 0 7.0000 166.6667 0 0
fmt = '%3d,%13.9g,%13d,%13d\n';
fprintf(fmt,Node.')
1, 0, 0, 0 2, 100, 0, 0 3, 200, 0, 0 4, 33.3333321, 0, 0 5, 66.6666641, 0, 0 6, 133.333328, 0, 0 7, 166.666672, 0, 0

댓글 수: 1

Mo A
Mo A 2021년 6월 18일
Thank you Stephen for your help. I'll be sure to include the code as text next time.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

태그

질문:

2021년 6월 18일

댓글:

2021년 6월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by