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

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;

 采纳的回答

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

类别

帮助中心File Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by