I have 6 columns of double data in .dat format, but i need to import only column 1 2 4 and 5. how do i do it

조회 수: 1 (최근 30일)
How to code it. Im new to matlab

답변 (2개)

Walter Roberson
Walter Roberson 2016년 7월 5일
There is no standard for .dat files. .dat is any data file format that the creating program wants to create. You will need to describe the format of the files for us to tell you how to load data from them at all.
It is often easiest to read all of the data and throw away the parts you do not need. However, for some text file formats, you can tell it which fields to save as it reads in the data, if you use textscan(). For binary files with strict format, memmapfile() can sometimes be used to read in only parts of the file.
  댓글 수: 1
Ashwin Ronaldo
Ashwin Ronaldo 2016년 7월 5일
편집: Ashwin Ronaldo 2016년 7월 5일
i have written; a = import('x.dat'); it opens up as 6 columns and 1024 rows. i need to plot data of column 1,2,4,5. i want to eliminate column number 3 and 6. how should it be done. I have attached a sample of data

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


Guillaume
Guillaume 2016년 7월 5일
1. Use a self-describing variable name rather than a.
2. You don't need to delete anything to plot certain columns. Use simple matrix indexing to pass only the columns of interest
plot(a(:, [1 2 4 5])) %only plots column 1 2 4 5
3. If you really want to delete columns, it's again simple matrix indexing:
a(:, [3 6]) = [] %delete columns 3 6
  댓글 수: 2
Ashwin Ronaldo
Ashwin Ronaldo 2016년 7월 5일
Sorry for the mistake in previous comment. I don't want it to be plotted, rather i would like to use quiver command. but i get error if i use quiver command
Walter Roberson
Walter Roberson 2016년 7월 5일
What error do you get with quiver()? Please show your line of code as well. My guess is that you need something like
quiver(a(:,1), a(:,2), a(:,4), a(:,5))

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

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by