Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.

I have highlighted in bold the line that is coming up with the error message:
function plottransect(1)
% input transno to define which transect is to be plotted
% plot transect for OS105
ctdFiles=dir(['Ctd_Transects_2018' filesep 'CTDdata*']);
gpsFiles=dir(['Ctd_Transects_2018' filesep 'GPSdata*']);
load(['Ctd_Transects_2018' filesep ctdFiles(transno).name])
load(['Ctd_Transects_2018' filesep gpsFiles(transno).name])
ct=CTDdata(:,1);
cT=CTDdata(:,4);
cS=CTDdata(:,8);
gt=GPSdata(:,1);
glon=GPSdata(:,5);
glat=GPSdata(:,6);
gT=interp1(ct,cT,gt);
gS=interp1(ct,cS,gt);
% Temperature subplot
figure(transno)
sp1=subplot(1,2,1);
scatter(glon,glat,20,gt,'filled')
Error: File: plottransect.m Line: 1 Column: 23
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other
syntax error. To construct matrices, use brackets instead of parentheses.

Answers (1)

function plottransect(1)
As stated on this documentation page "If your function accepts any inputs, enclose their names in parentheses after the function name."
1 is not a valid variable name. If instead you defined your function like:
function plottransect(in1)
then you could call it like this to make plottransect assign 1 to the variable in1 inside that call.
plottransect(1)

Categories

Asked:

on 7 Apr 2021

Commented:

on 8 Apr 2021

Community Treasure Hunt

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

Start Hunting!