help using feval with sigma points

Hi i have a function represent by:
function [y] = ffun(x,t);
if nargin < 2, error('Not enough input arguments.'); end
h=0.05;
m=2;
y=[x(1) + h*x(2) ;x(2) + h*(-9*x(1) + m*(1-x(1)^(2))*x(2))];
I am using 'feval' as:
xPredSigmaPts = feval(ffun,xSigmaPts(1:2,1:5),t)
where my xSigmaPts are:
xSigmaPts =
0 -2.4495 0 2.4495 0
6.0000 6.0000 2.8377 6.0000 9.1623
The answer I got using the above are:
xPredSigmaPts =
0.3000
6.6000
But this is not what I want. I want the 'feval' to evaluate/using each row and column of my data, xSigmaPts. So that the final result will be
xPredSigmaPts =
0.3000 -2.1495 0.1419 2.7495 0.4581
6.6000 4.1023 3.1215 1.8977 10.0785
How do I correct my 'feval' so that the final result as above? Thank you.

 採用された回答

Matt J
Matt J 2013 年 3 月 27 日
編集済み: Matt J 2013 年 3 月 27 日

0 投票

It's not feval that needs fixing. It's ffun:
y=[x(1,:) + h*x(2,:) ;x(2,:) + h*(-9*x(1,:) + m*(1-x(1,:).^(2)).*x(2,:))];

3 件のコメント

dab483
dab483 2013 年 3 月 27 日
編集済み: dab483 2013 年 3 月 27 日
Hi. I have try this before but have problems in here
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==>
m*(1-x(1,:).^(2))*x(2,:)
Thus error in
h*(-9*x(1,:) + m*(1-x(1,:).^(2))*x(2,:))
Any advise? Thanks.
Matt J
Matt J 2013 年 3 月 27 日
The version I posted for you does not have this problem. Try mine instead of your own.
dab483
dab483 2013 年 3 月 27 日
Oh my. Didn't notice the difference. So sorry about that. Now the problem solve. Thank you so much. :))

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunction Creation についてさらに検索

タグ

質問済み:

2013 年 3 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by