help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: Returning polynomial coefficients from matlabFunction as an array

 From: Colin Macdonald Subject: Re: Returning polynomial coefficients from matlabFunction as an array Date: Thu, 25 Aug 2016 09:30:46 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

```On 25/08/16 04:50, iceman wrote:
```
```the value of F returned should be

@(A, x) A11 .* x .^ 2 + A12 .* x + A13
where  A = [A11,A12,A13]

How should I go about doing this ?
```
```
Here's one approach using num2cell:

>> tmp = function_handle(p)
tmp =

@(A11, A12, A13, x) A11 .* x .^ 2 + A12 .* x + A13

>> F = @(A,x) tmp(num2cell(A){:}, x)
F =

@(A, x) tmp (num2cell (A) {:}, x)

>> F([5, 7, 11], x)
ans = (sym)

2
5⋅x  + 7⋅x + 11

>> F([5, 7, 11], 2)
ans =  45

This has some overhead, so maybe there is a better way.

Colin

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]