How can I read the text file and plot the graph

clear;
close all;
clc;
fid = fopen(' ');
t = textscan (fid,'%f%f','Delimiter','\n');
fclose(fid);
x = t{1};
y = t{2};
figure(1)
plot(x,y,'.-')
grid
title('SNR aganist frequency')
xlabel('frequency')
ylabel('SNR')

Answers (1)

You should start by taking a look at what you data file looks like by using the Import Data tool.
I have no idea what data from the file you are wanting to import, but textscan is not able on its out to figure out what 2 columns of floats you want to import. You need to provide more information that you have.
The 'HeaderLines' name-value pair might help, but because your data is interspersed with text sections intermittently, you are likely going to have to read the data in one line at a time (using fgetl) and first check that it is valid data before saving that line's data.

Categories

Tags

Asked:

on 10 Dec 2018

Answered:

on 11 Dec 2018

Community Treasure Hunt

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

Start Hunting!