"Invalid use of operator" importing lab data

7 次查看(过去 30 天)
I was given a file to import lab data, but it is not working properly.
Any ideas on what may be causing my error?
I am a matlab novice, so any input is appreciated.
Error using ME201tension (line 31)
Error: Invalid use of operator.
% Program to Load and Process Tension Test Data
%
%
% 1. Define all data files - follow a particular format of: Material
Materials=str2mat('Steel','Aluminum','Brass');
RunNumber=1; % assumes Run number 1 will be used in all cases or edit
% This can access all data files generated by the LabVIEW code,
% An example FileName is:
% Aluminum1.txt
%
% 2. Choose which file to process - there are many ways to do this, this is one way
MaterialNumberToProcess=1; % this could be a loop index, or edit as 1, 2 or 3
MaterialToProcess=deblank(Materials(MaterialNumberToProcess,:));
%
%
% 3. Load data - make sure you include a space inside the quotes after the load word
% Using : String Construction method
%
% EDIT THIS - Specify the path to a folder containing the data (this is an example)
FilePath=['U:\LAB\']; % end this string with a \
% For MATLAB to load files, the data file must be in a path with no space characters,
% instead the style is to use a capital letter just after where the space would have been,
% for example ‘Tension test' becomes ‘TensionTest'
% You should use this style throughout the laboratory course experiments.
%
FileName=[MaterialToProcess int2str(RunNumber)];
FileExtension='.txt'; % text file extension was used (include a period)
%
%
LoadString=['load' FilePath FileName FileExtension];
eval(LoadString)
% This evaluates the string LoadString as if it was typed onto the
% MATLAB command line. The data is placed into memory under the variable name
% to match the arbitrary value of the FileName string
%
Thanks for the help!

回答(1 个)

Satoshi Kobayashi
A space is missing in line 30.
LoadString=['load ' FilePath FileName FileExtension];

类别

Help CenterFile Exchange 中查找有关 Biological and Health Sciences 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by