Fixe the number of digit when creating matrix

조회 수: 1 (최근 30일)
Aurelie
Aurelie 2012년 8월 9일
I try to create a matrix with 2 objects: A a list of numbers with 4 digits B a matrix of numbers with 0 digits
I used M = [A, B]
But when I do that I lose the 4 digits of A and all numbers in my matrix have 0 digits. How to keep the numbers of digits of A while creating the matrix?
Thanks
  댓글 수: 2
Matt Fig
Matt Fig 2012년 8월 9일
Give an example of the numbers you mean. Are you mixing types? What does
whos A B
show?
Aurelie
Aurelie 2012년 8월 9일
Name Size Bytes Class Attributes
A 2420000x1 19360000 double
B 2420000x16 154880000 int32
A= 800.090909093618 800.181818187237 800.272727280855 800.363636374474 800.454545468092 800.545454561710 800.636363655329 800.727272748947 800.818181842566 ...
B= 0 0 44 0 7 16 0 31 3 0 12 0 0 3 0 0 0 0 0 0 0 0 36 0 0 28 0...
M= 800 0 0 44 800 0 7 16 800 0 31 3 800 0 12 0 800 0 3 0 801 0 0 0 801 0 0 0 801 0 36 0 801 0 28 0...
It is rounding A with 0 digits

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

채택된 답변

Matt Fig
Matt Fig 2012년 8월 9일
That is what I thought... Concatenating types like this will cause MATLAB to make M into an int32
M = [A,double(B)]
  댓글 수: 1
Aurelie
Aurelie 2012년 8월 9일
Yes it works now, I just started ti use matlab and now I think I need to learn about class of variables, thanks

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by