필터 지우기
필터 지우기

Creating a Matrix from Variables Window

조회 수: 3 (최근 30일)
Rightia Rollmann
Rightia Rollmann 2017년 1월 12일
댓글: Steven Lord 2017년 1월 12일
I create the variable G = []; in the Editor and then click on its name on Workspace and start typing in a 5 by 10 matrix there. Whenever I run the script, G becomes a 0-by-0 matrix from a 5-by-10 matrix. How can I tell MATLAB to change G to a 5-by-10 matrix and doesn’t change it to a 0-by-0 matrix?

답변 (2개)

Jan
Jan 2017년 1월 12일
The command "G = []" sets G to the empty matrix. If you do not want to do this, omit this command. Instead of using the Variable editor, you can write the contents directly to the code:
G = [1,2,3,4,5; 6,5,4,3,2]

Rightia Rollmann
Rightia Rollmann 2017년 1월 12일
What if my content is so big (e.g., a 1000-by-2000 matrix copied form Excel to Variables) and cannot just type it in like above?
  댓글 수: 1
Steven Lord
Steven Lord 2017년 1월 12일
Then you need to find another way to import that data into MATLAB. Since you mention Microsoft Excel, see if xlsread can handle your file.

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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by