how to resize different matrices
이전 댓글 표시
Hello everyone!
I need help with this, I have my matrix (Number1 of size 103x18) and another text matrix (Text1 of size 152x18). Now these are files that I'm reading in matlab from excel and taking specific information that is in specifc locations.
Now, my problem is that when I'm trying to move forward I face matrices of size (104x18) for the Number values and (153x18) or even (144x18) for my text. There is either an extra empty row that I'd want to remove or add because I want my Number matrices to be of the size 103x18 and the text ones 152x18. So that the data would be in the same location for them all.
I have no idea how to fix this, I tried ismember, I tried to somehow find the index of the extra or missing row but I cant seem to move forward. I don't know how to approach it.
Your help would be truly appreciated.
Thank you in advance!!
댓글 수: 6
Star Strider
2020년 1월 19일
Looking at a section of ‘Number1’ and ‘Text1’, it appears that there are a considerable number of NaN or empty elements (respectively) in those files. It miight be best to extract the elements that are not NaN or empty to different matrices first, then see how the dimensions match. It will be necessary to take care with that so that the essential structure of the matrices (relationships of the other elements) remains intact.
John Doe
2020년 1월 19일
John Doe
2020년 1월 19일
dpb
2020년 1월 19일
Dunno that we can do anything specific without seeing the input files and understanding what it is you're trying to retrieve.
If you used (the deprecated) xlsread to return the numeric and text values, there's almost always a mismatch in sizes as the numeric return and text return values return arrays beginning with where they find data...leading blank rows may be ignored and the numeric array won't have values at the end where there may be text, etc., etc., etc., ...
The raw third optional return variable will return the whole sheet region requested in its entirety, but then you have to parse the numeric and text data. This often is easier than trying to patch the other two together again, however, as you're discovering.
readtable can do a better job if the data are tabular; use the detectimportoptions routine first for best shot.
But, specifics rely entirely upon what the worksheet structure actually is and we simply don't have the information needed...
Image Analyst
2020년 1월 20일
John, regarding your recent edit, did you see my Answer below? I think it explains what you're seeing. If not, explain why not.
John Doe
2020년 1월 22일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!