Error with Octave

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Error with Octave

en4567
This post was updated on .
Good afternoon,

Could you help me fixing this problem please ?

error: octave_base_value::is_sorted (): wrong type argument 'class'
error: called from
    interp1 at line 193 column 3
    Loading_History at line 33 column 8
    main at line 40 column 18

Thanks a lot !


Reply | Threaded
Open this post in threaded view
|

Re: Error with Octave

Andreas Weber-6
Am 10.10.2016 um 16:35 schrieb en4567:
> Good afternoon,
> Could you help me fixing this problem :
> <http://octave.1599824.n4.nabble.com/file/n4680070/Error2.jpg>

Please add the error message as text, not as image.
You should also provide an example or description what you've done in
"Loading_History"

It looks like you are trying to call interp1 on a class?
-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Error with Octave

en4567
This post was updated on .
Thanks for your reply!

Here is the beginning of Loading_history until call of interp1

function  P_h = Load_Hist(Pr, i, tA, t0, deltat,steps)
  syms t q w
  P_h = zeros(1,steps+2);
  Prs = Pr*(1-(t/t0))*exp(-(t/w))
  Prsdt = int(Prs,t,0,t0)
  y = Prsdt - i
  ynew  =subs(y,'w',0:0.05:10);
  x= [0:0.05:10];
  wnew = interp1(ynew,x,0)

Excuse me but what does "call interp1 on a class" mean ?

Reply | Threaded
Open this post in threaded view
|

Re: Error with Octave

Mike Miller-4
On Mon, Oct 10, 2016 at 23:48:05 -0700, en4567 wrote:

> Thanks for your reply!
>
> Here is the beginning of Loading_history until
>
> function  Pressure_history = Loading_History(Pr, ir, tA, t0, deltat,steps)
>   syms t q w
>   Pressure_history = zeros(1,steps+2);
>   Psr = Pr*(1-(t/t0))*exp(-(t/w))
>   Psrdt = int(Psr,t,0,t0)
>   y = Psrdt - ir
>   ynew  =subs(y,'w',0:0.05:10);
>   x= [0:0.05:10];
>   wnew = interp1(ynew,x,0)
>
> Excuse me but what does "call interp1 on a class mean" ?

It means that you are calling the function interp1 on an argument that
is a symbolic variable (an object of class "sym").

The function interp1 works on numeric values but not on symbolic values.
Octave is primarily a numerical tool, not an algebraic/symbolic engine.

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Error with Octave

en4567
Thanks!

Does that mean it wont' work on OCtave ?
Reply | Threaded
Open this post in threaded view
|

Re: Error with Octave

nrjank

On Oct 11, 2016 4:54 AM, "en4567" <[hidden email]> wrote:
>
> Thanks!
>
> Does that mean it wont' work on OCtave ?
>
>

Well, obviously what you're trying to do won't work. :)

Looks like you're trying to substitute a numerical range back in for the w in order to get an array you can feed to interp1. Unfortunately it seems the output of subs is still symbolic, and interp1 can't operate on symbolic objects.

I don't generally work with symbolics, so I don't know if (a) there's a way to do a type conversion for numerical symbolic variable. Or (b) if there's a symbolic interpolation function.

If you have reason to believe this should work (matlab compatibility, documentation, let us know)


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Error with Octave

Colin Macdonald-2
On 11/10/16 05:10, Nicholas Jankowski wrote:
> I don't generally work with symbolics, so I don't know if (a) there's a
> way to do a type conversion for numerical symbolic variable. Or (b) if
> there's a symbolic interpolation function.

(a) yes, cast to double:

 >> ynew = double(subs(y,'w',0:0.05:10));

But I think it'll be slow and give lots of warnings.  It might be better
to do something like:

 >> y_fcn = function_handle(y);
 >> ynew = y_fcn(0:0.05:10);

(b) no, at least not yet.

> If you have reason to believe this should work (matlab compatibility,
> documentation, let us know)

+1 for this.  "Substituting a double array into a symbolic expression"
seems to be a common thing that folks want to do.  Is there is supposed
to be an easier way?

best,
Colin

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Error with Octave

en4567
Good morning,

Thanks for your replies. I will try your solution as soon as possible and will come back to tell if it has worked or not !