フィルターのクリア

If there is a method to define the size of unknown vector x rather than this ???

1 回表示 (過去 30 日間)
M.Shaarawy
M.Shaarawy 2018 年 2 月 24 日
回答済み: Steven Lord 2018 年 2 月 26 日
I want to define the size of x vector, rather than this.. x=sym('x%d%d', [27 1]) where my size is 27*1

採用された回答

John D'Errico
John D'Errico 2018 年 2 月 24 日
編集済み: John D'Errico 2018 年 2 月 24 日
x = sym('x',[27,1]);
  3 件のコメント
Karan Gill
Karan Gill 2018 年 2 月 26 日
Post your full code and data. Your question is not clear otherwise. If you get an error, try a search for the error message to understand what is happening.
M.Shaarawy
M.Shaarawy 2018 年 2 月 26 日
function y = simple_fitness(x) load A.mat; % 27*27 matrix load obs.mat; % 27*1 vector y=norm(A*x-obs,2);

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 2 月 26 日
If you're passing a function handle to costfun into some optimizer, you don't have to create x in your code (and you should not do so.) The optimizer will pass an x it has created into your function as the input argument and you just need to use it.
As an efficiency note, I would avoid calling load inside your objective function. Your objective function is likely to be called many times and all that disk access will take time. Call load twice outside the function and pass the variables you loaded into your objective function as extra parameters using one of the techniques described on that documentation page.

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by