How do I use a function from File Exchange?

3 次查看(过去 30 天)
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 个评论
Torsten
Torsten 2022-3-29
Did you assign values to "direction" and "speed" ?
Victoria K
Victoria K 2022-3-29
Yes.
I have direction and speed vectors that are both 8713 x 1 vectors.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2022-3-29
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 个评论
Victoria K
Victoria K 2022-3-29
编辑:Victoria K 2022-3-29
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 2022-3-30
编辑:Stephen23 2022-3-30
"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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by