I need help with a created function I made. Could someone please tell me what I did wrong?

조회 수: 1 (최근 30일)
I created a function to put all of my ascii files I have in one folder into one larger file with the data in the correct sequence. I got an error on the first line, though, so I can't run it. My code should be right if I can eliminate this error. The error reads: Error using read_test_data_jp (line 32) Not enough input arguments. I can't provide the files that I'm using or the info in them, but I tried to make some dummy ones to look at.
function read_test_data_jp('Y:\Prelaunch\Drive_Acceleration\ML Move to and from Pad B\read_test_data_jp') % start_directory – path to data
AllFiles = [];
filenames = dir('Y:\Prelaunch\Drive_Acceleration\ML Move to and from Pad B\MovetoPadB-ascii'); % starting directory
for ii = 3:length(filenames) % Start at third file( i.e., don't include "." and "..")
%Get the filename
filename_timestamp = filenames(ii).name;
% parse data filename_timestamp for the timestamp information
semicolonIndex = findstr(';',filename_timestamp);
commaIndex = findstr(',',filename_timestamp);
day = str2num(filename_timestamp(1:semicolonIndex(1)-1));
hour = str2num(filename_timestamp(semicolonIndex(1)+1: semicolonIndex(2)-1));
min = str2num(filename_timestamp(semicolonIndex(2)+1: semicolonIndex(3)-1));
sec = str2num(filename_timestamp(semicolonIndex(3)+1: commaIndex(1)-1));
% read space or tab-delimited data; if tab use '\t' instead of ' '
DataFile = dlmread(fullfile('Y:\Prelaunch\Drive_Acceleration\ML Move to and from Pad B\read_test_data_jp',filename_timestamp),' ');
% Now correct the first column of data by adding the seconds that were read in from the file name
DataFile(:,1) = DataFile(:,1) + day*86400.0 + hour*3600.0 + min*60.0 + sec;
% Append files as you loop through all of the files into one matrix
AllFiles = [AllFiles;DataFile];
end
%Write tab delimited data to a file
dlmwrite('Appended_Test_Data_Output.txt',AllFiles,'delimiter','\t'); end
  댓글 수: 2
Adam
Adam 2016년 6월 16일
A function has to take a variable name as argument, not a hard-coded string. You then call it with the string you want to pass in, running it from command line or a script or another function.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by