Wind rose as a scatter plot --Function definitions are not permitted in this context

1 view (last 30 days)
I have two columns, wind direction and wind speed. i want to create a wind rose as a scatter points using this variables. Currently I am trying to use a script named Wind rose as scatter in mathworks page. Since I am relatively new to MATLAB, while I tried to run the program I am getting the following errors
Error using ScatterWindRose (line 31)
Not enough input arguments
or
Error: Function definitions are not permitted in this context.
Can any one help me how to solve this? Also how to input the X & Y variables via input command?

Accepted Answer

Voss
Voss on 20 Apr 2022
You get this error:
Error using ScatterWindRose (line 31)
Not enough input arguments
if you run ScatterWindRose by clicking the run button in the MATLAB Editor or hitting the F5 key, because both of these things run whatever function or script is open in the Editor with no inputs. (ScatterWindRose in particular expects at least 2 inputs, so you'd get the same error if you were to run it with fewer than 2 inputs.)
Give it at least 2 inputs:
subplot(1,2,1)
X = 180*randn(1,100);
Y = randn(1,100);
ScatterWindRose(X,Y)
(they don't have to be called X and Y - they don't have to be called anything)
subplot(1,2,2)
ScatterWindRose(180*randn(1,100),randn(1,100))
The other error:
Error: Function definitions are not permitted in this context.
may be happening because you modified ScatterWindRose, or it may come from some other file you are working on. I don't know, but you can take the ScatterWindRose.m attached here, because I just downloaded it from the File Exchange link you provided.
  2 Comments
Akhil Narayanan
Akhil Narayanan on 20 Apr 2022
Thanks for the answer, but instead of inputting random numbers can you please tell how to insert a set of X & Y values, i.e., one month observation values for wind speed and direction?
Voss
Voss on 20 Apr 2022
Edited: Voss on 20 Apr 2022
How to do that depends on how your data is stored. Without knowing that, all I can tell you is you have to get it into your MATLAB workspace somehow (if it's in a mat-file you would use load; if it's in a text file you might use readmatrix or readtable, etc.). Then once you have that data in your workspace, call scatteredWindRose like I did with the random values.
[X,Y] = % data from somewhere
ScatterWindRose(X,Y)
(To be clear, these commands, and the commands I showed previously, would all be executed from the command-line or written in an m-file that you create - but NOT in ScatterWindRose.m.)

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!