0

I need to make a radar plot, I googled it and got this: http://www.mathworks.co.uk/matlabcentral/fileexchange/33134-radar-plot/content/radarPlot.m

but it gives an error I'm not sure how to solve.

The error is Error: File: radarplottest.m Line: 17 Column: 1 Function definitions are not permitted in this context.

Any tips?

user2587726
  • 169
  • 2
  • 11

1 Answers1

1

Did you copy the function and paste it into a script file you were working on?

If you did something like add your own code at the top of the file (say, to load data), that will give you the error you're seeing. You should have one file, "radarPlot.m", which contains this function, and then "radarplottest.m" could be something like a script containing data loading/pre-processing and then calling the radarPlot function on the appropriate data.

All you need in radarplottest.m is something like:

Data = % define some random test data or load some existing data
radarPlot(Data); % requires radarPlot.m to be on your path so Matlab can find it
nkjt
  • 7,825
  • 9
  • 22
  • 28
  • A sloppier alternative is to comment out the `function` declaration line line. – Buck Thorn Jul 26 '13 at 13:39
  • I've tried that, I now get this error: Attempt to execute SCRIPT radarplot as a function: C:\Send to Pearce\TXT 580\radarplot.m Error in radarplot (line 26) radarplot(Data); – user2587726 Jul 29 '13 at 14:20
  • It looks you like added the code above to "radarplot.m". That file must only contain what is shown on the file exchange. The code I gave you should be in a different named file, e.g. "radarplottest.m" or run from the command line. I suggest you read the Matlab documentation about the differences between a function and a script, as well. – nkjt Jul 29 '13 at 14:56