"Invalid use of operator" importing lab data

7 views (last 30 days)
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!

Answers (1)

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

Categories

Find more on Biological and Health Sciences in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!