'Array indices must be positive integers or logical values' error for directory use
Ältere Kommentare anzeigen
Hello Everyone,
I am currently undergoing a project in which I must create a code that analyses a potentially infinite amount of data. As such, I am using a directory and the csvread function in conjunction. I have been told that the continued use of csvread in my code slows down the code and makes it less efficient so I am therefore trying to load the csvread function into the RAM and create a shortcut that links it to my directory. I, however, keep getting an error saying 'Array indices must be positive integers or logical values.' Please see the relevant section of my code attached. Thanks.
%% Import and Sort Data
files = dir('\\nask.man.ac.uk\home$\Vortex Shedding\Used Data\*csv');
[r inx] = sort({files.name});
files = files(inx);
(csvread(files(i).name)) == Signal
%% Calculate Turbulence Intensity
for i=1:length(files)
ave = mean(Signal);
Average(i,:) = ave(:,3);
RMS = sqrt((sum((((Signal)-mean(Signal)).^2)))/(length(Signal)));
RootMeanSquare(i,:) = RMS(:,3);
TurbulenceIntensity(i,:) = (RootMeanSquare(i)/Average(i))*100;
end
2 Kommentare
What is this supposed to be doing?:
(csvread(files(i).name)) == Signal
Given that i is not defined previously in your code, its value is going to be sqrt(-1), which is unlikely to be very useful as an index. Even if you use a valid index, this line seems to import some data and then compare it against Signal... and then discard those results (because you did not assign the output to any variable). Why do you want to throw away the result of that comparison?
"I am therefore trying to load the csvread function into the RAM and create a shortcut that links it to my directory."
Data can be imported (or loaded) from a file into MATLAB's memory. A function is called or executed. What does it mean to "load" a function?
What exactly is "a shortcut that links it to my directory" ?
Jack Radcliffe
am 14 Dez. 2018
Bearbeitet: Stephen23
am 14 Dez. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Standard File Formats finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!