Clear Filters
Clear Filters

How do I use a function from File Exchange?

5 views (last 30 days)
Victoria K
Victoria K on 29 Mar 2022
Edited: Stephen23 on 30 Mar 2022
Hi all,
I am not very familiar with functions, but I need to use one from file exchange to create a diagram.
I want to create a wind rose plot using this function: https://www.mathworks.com/matlabcentral/fileexchange/47248-wind-rose
I have my two vectors for direction and speed, but I am unable to get the function to work. I've tried using WindRose(direction,speed) at the top of the script. However, I get an error saying 'All functions in a script must be closed with an 'end'.
Could I get some guidance on how to use the function?
  2 Comments
Torsten
Torsten on 29 Mar 2022
Did you assign values to "direction" and "speed" ?
Victoria K
Victoria K on 29 Mar 2022
Yes.
I have direction and speed vectors that are both 8713 x 1 vectors.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 29 Mar 2022
Use the Add-on Explorer to install the File Exchange contribution.
I checked the contribution. Some of the files define scripts but no functions inside, and other files define functions with no scripts. None of them define functions inside scripts. You would have had to merge the files, or edit them, or else perhaps the error is in code you created.
  2 Comments
Victoria K
Victoria K on 29 Mar 2022
Edited: Victoria K on 29 Mar 2022
Sorry, I'm not sure if I'm catching on.
My code is three lines, and all it does is import the direction and speed data. The attached file is the direction and speed data columns I am using.
So I can't use this function because it is not written to include other scripts? But some of the examples I have seen of this function include script too.
Stephen23
Stephen23 on 30 Mar 2022
Edited: Stephen23 on 30 Mar 2022
"So I can't use this function because it is not written to include other scripts?"
It is not clear what "not written to include other scripts" means. That FEX submission consists of perfectly ordinary scripts and functions which can be called from any other scripts and functions.
" I get an error saying 'All functions in a script must be closed with an 'end'."
As that FEX submission does not include any functions defined in scripts (as Walter Roberson explained) the cause of that error is due to some other code or due to someone making changes to the FEX code after downloading it.
Lets download it, run it, and see if we get any errors. The script TEST_SUBPLOTS calls both WINDRANDOMDISTRIB and WINDROSE functions, so calling that seems like a good test:
run Test_Subplots

Sign in to comment.

Categories

Find more on Downloads 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!