Accessing Data Structures: Runs in command line, not in script... Errors include: Invalid Syntax at '=' and Parse error at ')'

1 view (last 30 days)
I don't usually post to on here, but I can't seem to figure this one out. I have some code where I use a structure to store important information. Some of these are vectors/arrays and others are character arrays. Below are some snippets from my code:
I have 25 geophysical lines, so the first thing I do is initialize the structure:
geoLineStruct(1:25,1) = struct('LineName',' ','sSoL',zeros(1,2),'sEoL',zeros(1,2),...
'rSoL',zeros(1,2),'rEoL',zeros(1,2),'dType',0,'resOffset',0, 'sLength',0.0, ...
'rLength',0.0,'topoFileLoc',' ','seisDataLoc', ' ', 'resDataLoc', ' ');
Then I simply fill the structure one by one with my required information, this is information I would normally have to type in over and over again
geoLineStruct(1,1).LineName = 'BW-051713';
geoLineStruct(1,1).sSoL = [467161 4559433];
geoLineStruct(1,1).sEoL = [467256 4559272];
geoLineStruct(1,1).dType = 1;
geoLineStruct(1,1).resOffset = 0;
geoLineStruct(1,1).sLength = 190;
geoLineStruct(1,1).rLength = 165;
.
.
.
This is were the problem gets weird! I get an parse error if I try to reassign one of the values of the structure to another variable, but this only happens in the script! For example:
temp = geoLineStruct(1,1).sSoL
I get a little red squiggly under the ")" with an error that says, "Parse error at ')': usage may be invalid MATLAB syntax.
This exact command perfect if I type it (or copy it) into the command window.
>> temp = geoLineStruct(1,1).sSoL
temp =
467161 4559433
This code was working just fine last week, and I got this error, when I tried to run it this morning. Does any one know why I am getting a parse error, i.e. Matlab thinking this is a logical? Or a way to tell Matlab to ignore it?
  1 Comment
Brady Flinchum
Brady Flinchum on 13 Jan 2015
Never mind I figured it out! I forgot a square bracket on my last definition. Don't kill yourself trying to answer this one. I didn't post the entire code so you won't figure it out.
geoLineStruct(1,1).resDataLoc = [path2DropBox,'Blair-Wallis-Hydrogeophysics/DataProcessing/051713/Resistivity/GMT-Results/051713_resistivity.gmt.xzv';
NEEDED to BE:
geoLineStruct(1,1).resDataLoc = [path2DropBox,'Blair-Wallis-Hydrogeophysics/DataProcessing/051713/Resistivity/GMT-Results/051713_resistivity.gmt.xzv'] ;

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!