copy text and numeric data from excel and make a matrix in matlab
조회 수: 38 (최근 30일)
이전 댓글 표시
I have following data in excel –
A 1 5
B 2 6
C 3 7
D 4 8
E 5 9
F 6 10
I want to create a matrix K in matlab using above data-
K=[A 1 5
B 2 6
C 3 7
D 4 8
E 5 9
F 6 10];
If I directly copy in matlab I get following error:
“Error using horzcat
Dimensions of arrays being concatenated are not consistent. “
“K=[A 1 5”
Is it possible to directly copy the combination of text and numerical data from excel and paste it into matlab so that K can be a 6*3 matrix?
Actually I want to use K(:,1) in later part of my code. For example- I want to get
K(1,1)= A
K(2,1)= B
.
.
.
K(6,1)=F
My real K matrix is huge in the excel file. I just showed here only few.
Thank you.
댓글 수: 2
per isakson
2019년 4월 28일
I don't think it's possible.
"K matrix is huge", see readtable Create table from file and xlsread (Not recommended) Read Microsoft Excel spreadsheet file
Walter Roberson
2019년 4월 28일
The problem is combining text and numeric in a single array. The array needs to be a cell array or a table to do that usefully.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!