필터 지우기
필터 지우기

How to assign variables to imported data columns

조회 수: 69 (최근 30일)
Rahma Belaid
Rahma Belaid 2017년 9월 4일
댓글: Stephen23 2022년 2월 21일
I am working on a project where I have to load a .txt file that has 4000 raw and 2 columns. I would like to use the second column only in one of my calculations. How can I do that? I tried to assign variable x to be the first column and y to be the second, but I didn't know how.

채택된 답변

Wonsang You
Wonsang You 2017년 9월 4일
Let's assume that you have the text file, including numbers of 4000 rows and 2 columns, called "data.txt". Then, try the following commands.
M = dlmread("data.txt");
X = M(:,2);
Then, X is a column vector including just the second column. I wish it is helpful for you.
  댓글 수: 2
Emily hand
Emily hand 2022년 2월 21일
What does the "M" do?
Stephen23
Stephen23 2022년 2월 21일
"What does the "M" do?"
M is just the name given to the matrix of imported data.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by