2
$\begingroup$

I am importing a matrix from MATLAB. However, there are some redundant items added in the imported matrix.

For example, the imported matrix is a binary matrix. After import, it looks like this

{{{{{0, 1, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`,
  0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`,
  0.`, 0.`, 0.`, 0.`, 1.`, 0.`, 0.`, 0.`, 0.`, 1.`, 1.`, 0.`, 0.`,
  0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`,
  0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`,
  0.`}, {1.`, 0.`, 1.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 
  0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 
  0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 1.`, 1.`, 0.`, 0.`, 0.`, 0.`, 
  1.`, 1.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 
  0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 0.`, 
  0.`, 0.`, 0.`, 0.`},......}}}}};

How can I get rid of . and `?

There are some additional brackets also. However, the brackets are not an important issue.

The dimension is found to be {1, X, Y}. Where does this 1 come from?

$\endgroup$
6
  • $\begingroup$ What command do you use for importing? the leading 1 in the dimensions is probably from there. Please give the details. $\endgroup$
    – Roman
    May 20 '19 at 12:58
  • $\begingroup$ I am using Import? $\endgroup$ May 20 '19 at 13:00
  • $\begingroup$ By "details" I mean write down the command with all options. Otherwise the reader needs to guess that you've used Import with no further options. The easier you make it for the reader, the better your chances of getting help. $\endgroup$
    – Roman
    May 20 '19 at 13:02
  • $\begingroup$ Import["C:\Users\dipak\Desktop\data.mat"] $\endgroup$ May 20 '19 at 13:03
  • 2
    $\begingroup$ Matlab does not know integers. First axiom of Matlab: Everything is a matrix of doubles (machine precision real numbers). $\endgroup$ May 20 '19 at 14:11
3
$\begingroup$
Round[data]

{{{{{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ...}}}}

Or Round[First[data]] to get rid of the first dimension of length 1.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.