How do I use a function from File Exchange?

9 ビュー (過去 30 日間)
Victoria K
Victoria K 2022 年 3 月 29 日
編集済み: Stephen23 2022 年 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 Center および File ExchangeDownloads についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by