Read data from .txt file

조회 수: 1 (최근 30일)
Ashesh Choudhury
Ashesh Choudhury 2020년 10월 17일
답변: Athul Prakash 2020년 10월 23일
The text file will contain two information.
  1. The number of equations.
  2. The augmented matrix.
I want to save the number of equations in a variable 'n' and the augmented matrix in a matrix 'A'. How can I do it? The input text file data will be for example:
3
4 2 3 6
5 6 7 8
3 6 7 9
So, I want to take input in my program from this text file. And assign: n=3 and A=[4 2 3 6; 5 6 7 8; 3 6 7 9].
Please help.

답변 (1개)

Athul Prakash
Athul Prakash 2020년 10월 23일
I recommend trying the 'Import Data' button on the Home tab in the Matlab toolstrip. After selecting your .txt file in the tool, you may interactively crop the data you need and save into a variable in your workspace.
There are multiple tools and options to import the data you mentioned - for an overview you may read this documentation page:
Hope it helps!

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by