필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How do i skip the first 4 rows and create a diagram from the values?

조회 수: 1 (최근 30일)
Dennis Wikan
Dennis Wikan 2017년 4월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
I want to make diagrams from all these values and ignore the definitions in the first 4 rows.
This is what I have so far.
fid=fopen('OG.txt','rt')
M = dlmread('OG.txt',';')
for i=1:4, fgetl(fid),end
A=fscanf(fid,'%f',[4,inf])';
fclose(fid)
subplot(2,1,1)
plot(A(:,1), A(:,3), A(:,1), A(:,4))
legend('obs1','obs2')
subplot(2,1,2)
plot(A(:,1), A(:,2))

답변 (1개)

JohnGalt
JohnGalt 2017년 4월 4일
skipping the first 4 rows... rather than use the colon operator (':') by itself... use ('5:end')
for example
a = 1:8;
a(5:end) % = [5 6 7 8]
The ':' by itself is the same as '1:end', i.e. a(:)==a(1:end)
Reading in the data you will probably have an easier time with the 'textscan' function. You can specify delimiters (';' in your case). As your first few lines aren't marked with a symbol to show that they're comments/heading... you'll probably have to load all the data and then remove the first 4 rows.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by