Showing me wrong Matrix Size.

조회 수: 6 (최근 30일)
Amit Chakraborty
Amit Chakraborty 2021년 9월 23일
댓글: Walter Roberson 2021년 9월 23일
fds = fileDatastore(" " );
N= cell2mat(fds.Files);
kk= ones(64,1);
OO= N.*kk;
  • I have created a Data store with a matlab data. The original size of the data was : 2031616x64.
  • In the second line of the code I just convert the file from the cell type
  • Created the ones matrix
  • when i am trying to multiply , the reultant varibale "OO" is having the wrong size: 64x161. But if I have done it in a normal way (without creating Datastore) it's size would have been : 2031616x1 which is basically correct and I need.
My question is that , what mistake I am making here? I am newly working with the "Datastore" stuffs in MATLAB.
Thanks in Advance.

채택된 답변

Walter Roberson
Walter Roberson 2021년 9월 23일
N= cell2mat(fds.Files);
The Files field of a FileDataStore is a cell array of character vectors that holds file names. When you cell2mat() that, you get a character vector or character array. Character vectors and character arrays are treated as numeric when you do numeric operations -- for example,
'A' + 1
looks up the Unicode code position for the letter 'A' (which is 65), and adds 1 to that code (getting 66 -- which happens to be the code position for the letter 'B')
Thus, you are doing mathematics on the characters of file names, not on the contents of the files.
  댓글 수: 2
Amit Chakraborty
Amit Chakraborty 2021년 9월 23일
편집: Amit Chakraborty 2021년 9월 23일
@Walter Roberson Thank you for your explanation. It clears my confusion.
Will it be possible for you to show me the correct process of doing the multiplication in such case? I mean to say that : multiplication of the content (of data store) with the another numeric matrix.
I must mention that: I want to do the multiplication but do not want to extract out the data from the data store.
Walter Roberson
Walter Roberson 2021년 9월 23일
You might possibly be able to use a transform store; https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.transform.html
Transform stores do not perform the transformation until the data is needed by the program. But at some point, the multiplication needs to be done.
It looks to me as if in your case, you could just sum() the data along its second dimension instead of coding in terms of multiplying by a matrix.

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

추가 답변 (1개)

Fabio Freschi
Fabio Freschi 2021년 9월 23일
multiply without the 'dot'
OO= N*kk;

카테고리

Help CenterFile Exchange에서 Big Data Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by