How do I properly import this text file and create a plot from it?

6 views (last 30 days)
Hello,
Hello, I am trying to import the values from a text file and create a plot from it. However, it is unable to read the txt file and when I check the variables, it shows the text file, but none of the variables. When I run the code, this shows up. Error using importdata (line 136) Unable to open file.
Error in 360_Hmk1 (line 5)
A1=importdata('0012data.txt',' ',2);"
I tried to convert my text file from a table to a cell array but this didn't work in that it didn't even show up as a variable. I appreciate your help. Thanks. Heres the code that I used:
if true
% code
end
%%Creating plot of airfoil cross section.
clear all;
% Import both data from txt. files
A1=importdata('0012data.txt',' ',2);
AF1x = A1.data(:,1);
AF1y = A1.data(:,2);
AF1Cp = A1.data(:,3);
plot(AF1x,AF1y,AF1Cp)
grid on;

Accepted Answer

Walter Roberson
Walter Roberson on 29 Aug 2015
I suspect that your current directory is not set to the directory that the file is in. Use the cd command to change current directory

More Answers (1)

Ravi Prathipati
Ravi Prathipati on 29 Aug 2015
Thank you. It was the directory.

Community Treasure Hunt

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

Start Hunting!