필터 지우기
필터 지우기

how to resize different matrices

조회 수: 1 (최근 30일)
John Doe
John Doe 2020년 1월 19일
댓글: John Doe 2020년 1월 22일
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
Image Analyst
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
John Doe 2020년 1월 22일
[numbers, strings, raw], I used this to read my excel files but there was still a shift. The shift came from the excel sheets themselves. Not all the data where filled in, in the same location (there was one cell shift or so). So I re-adjusted my raw data then I re-wrote the excelsheets, so that when I try to read the data its all in the same position.
Your answer helped me see the raw data and how it affected my number and text data. Thank you so much! :)

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

채택된 답변

Image Analyst
Image Analyst 2020년 1월 19일
The numbers and the strings will have different upper left locations in your variables. For example, if you have string row headers all along row 1, and file names going down column 1, and starting from B2 across and down you have all numbers, then you do
[numbers, strings, raw] = xlsread(filename);
strings will be taken starting from A1 across and down, while numbers will be taken from B2 across and down. So strings{1,1} will be cell A1 from the workbook, while numbers(1,1) will be from cell B2 of the workbook. Thus they don't align as you've seen.
The way to "fix" that and make sure if you put in a cell location it will be taken from the same location as in the workbook is to use the raw variable - the third output argument of xlsread.

추가 답변 (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