Wind rose as a scatter plot --Function definitions are not permitted in this context
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Voss
2022-4-20
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 个评论
Voss
2022-4-20
编辑:Voss
2022-4-20
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.)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!