MATLAB Answers

How do I pick specific rows of a txt file and plot data?

1 view (last 30 days)
Eva G
Eva G on 30 Nov 2020
Answered: Star Strider on 30 Nov 2020
Hi ! How can I choose specific lines with values from a txt file that contains both letters and numbers? For example in the attached file I want to delete the first 14 rows and make a spectra plot of the two columns.

  0 Comments

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 30 Nov 2020
Try this:
D1 = readmatrix('collagen405.txt', 'HeaderLines',14);
x = D1(:,1);
y = D1(:,2);
figure
plot(x, y)
grid
title('Spectrum Plot')
xlabel('Frequency')
ylabel('Amplitude')
Also consider:
figure
semilogy(x(y>0), y(y>0))
grid
title('Spectrum Plot')
xlabel('Frequency')
ylabel('Amplitude')
.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!