How to get import data to count in a for loop

2 views (last 30 days)
James
James on 11 Apr 2014
Edited: Andrew Newell on 11 Apr 2014
Hi,
I am using a for loop that reads off a "master file" that just has a bunch off other files listed on it so I can have matlab run through multiple data sets at one time. The first loop runs through without a problem, I get my plot at the end, when it goes back through it gives me an error that is as follows,
Error using importdata (line 136)
Unable to open file.
Error in Creating_master_file (line 66)
Trial1 = importdata(filename);
I checked the file name and everything and that is not the problem. I don't know if Matlab is having trouble creating a new structure, or if i need to index it so it counts and creates a new one each time. How do I fix this error. Here is my code, if that helps at all. Thank you
clear; clc;
[num txt raw]=xlsread('vehicle master file.xlsx');
for(x=1:length(txt))
x
filename=txt{x};
Trial1 = importdata(filename);
num=Trial1.data;
txt=Trial1.textdata;
txtcolumn7=txt(32:end,7);
index1 = find(ismember(txtcolumn7,'response delay','legacy'));
num5=num(32:end,5);
DR=num(index1,5);
%remove NaN
DR1=Snip(DR,nan);
%find and remove 10's
values10=find(DR1==10);
DR1(values10)=[];
I have cut out a lot past this, but that is just a bunch of plotting commands and stuff that is not affecting this.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!