2 Errors: Conversion to double from function_handle is not possible and attempt to reference field of non-structure array.

What mistake am I making here?
clc
x0 = [0.01, 1, 10 + 273.15, 8, 1];
options = optimset('PlotFcns',@optimplotfval);
fitnessfcn = @(x)Lobo(x(1), x(2), x(3), x(4), x(5));
[X, fval] = gamultiobj(fitnessfcn, 5, [], [], [], [], [], [], options);
X
disp(X);
d0 = 0.01:10;
Qr{:,1} = @(x)Lobo(x(1), x(2), x(3), x(4), x(5));
plot (d0,Qr{:,1});
xlabel('(d0)');
ylabel('flux (qr)');

4 件のコメント

What is this?
Qr{:,1} = @(x)Lobo(x(1), x(2), x(3), x(4), x(5));
Stephen23
Stephen23 2018 年 3 月 13 日
編集済み: Stephen23 2018 年 3 月 13 日
See earlier questions:
@Devdatt Thengdi: the function plot plots numeric data. The variable Qr is cell array or table containing a function handle. If you want to use plot then you will need to generate numeric data first, else you could use ezplot or fplot to plot the function.
Stephen23
Stephen23 2018 年 3 月 13 日
@Devdatt Thengdi: call that function! If the function has been written using vectorized code then simply call it with a vector of the independent variable values. If the function is not vectorized use a loop or arrayfun.
You might like to try using ezplot first.
I used fplot. New error:
Attempted to access x(2); index out of bounds because numel(x)=1.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with Optimization Toolbox についてさらに検索

タグ

質問済み:

2018 年 3 月 13 日

コメント済み:

2018 年 3 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by