Variable unrecognized in function
4 ビュー (過去 30 日間)
古いコメントを表示
so i wrote this code and it seems to work fine on its own but everytime I try to run it as a function it keeps showing variable unrecognized. The variable is column vector imported from excel.
0 件のコメント
回答 (1 件)
Cris LaPierre
2022 年 2 月 21 日
It would appear, based on the error message, that your function does not create a varibale Nu. Make sure you are either passing the variable into your function, or that you create it inside the function.
2 件のコメント
Cris LaPierre
2022 年 2 月 21 日
You could import them inside your function, but the more typical way to get data into a function is to pass it in as one of the inputs. See here.
Here's a simple example, but what is passed in could be anything you can capture in a variable.
% scripting
a = 5;
b = a.^2
% same calculation, but now performed in a function.
c = myfunc(a)
function out = myfunc(in)
out = in.^2;
end
参考
カテゴリ
Help Center および File Exchange で Data Export to MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!