Problem symbolic on windows

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

Problem symbolic on windows

Stef Pillaert
Hello,
I have this code: it runs in matlab (if "pkg load symbolic" is uncommented),
it doenst in octave - altough I think it "used" to run one year ago ;-):

% sprongfuncties in Matlab/Octave
% Geheugen leegmaken
clc
clear
close all
% basisgegevens
EI=1000;

%deze regel is enkel nodig in octave om symbolisch te kunnen werken, maar in
matlab niet.
pkg load symbolic

%de variabele x declareren we als symbolisch, zodat er symbolisch mee kan
gerekend worden.
syms M(x) C1 C2;

%De M-functie:
M(x)=13*x-heaviside(x-2)*15*(x-2)-heaviside(x-4)*9*(x-4)^2/2;
%we maken de eerste van 2 subplots
subplot(2,1,1)
fplot(M(x),[0,6]);
intM(x)=int(M(x))+C1;
intintM(x)=int(intM(x))+C2;
alfa(x)=-intM(x)/EI;
z(x)=-intintM(x)/EI;
rndvw=[z(0)==0,z(6)==0];
onbek=[C1,C2];
opl=solve(rndvw,onbek);
C1=opl.C1
C2=opl.C2
%de tweede subplot
subplot(2,1,2)
fplot(eval(z(x)),[0,6]);
%de doorbuiging in het midden, eveneens in "variable precision arithmetic":
eval(z(3)),vpa(eval(z(3)))
%oppervlakte onder de vervormingslijn (evt. nuttig voor invloedslijnen)
int(eval(z(x)),[0,6]),vpa(int(eval(z(x)),[0,6]))

When I run it (on Windows10), it gives me this error message:

error: isalnum: not defined for class
error: called from
    fplot at line 100 column 3
    Sprongfuncties_in_Octave at line 19 column 1
>>

Any idea what is happening here?
Many thanks,
Stef




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Problem symbolic on windows

nrjank
On Wed, Feb 5, 2020 at 11:20 AM Stef Pillaert <[hidden email]> wrote:
 
error: isalnum: not defined for class
error: called from
    fplot at line 100 column 3
    Sprongfuncties_in_Octave at line 19 column 1



stepping through the code, the error occurs at the line:

fplot(M(x),[0,6]);

where M(x) is defined as a symbolic function. It appears that at least currently, fplot in Octave cannot handle a symbolic function. (i did try with a simple polynomial function to verify it wasn't something unique to the function you used.)  I can't confirm whether or not this is a regression from a previous version of symbolic, but did confirm that Matlab 2019a is able to execute the same fplot command without issue.


Reply | Threaded
Open this post in threaded view
|

Re: Problem symbolic on windows

Mike Miller-4
On Wed, Feb 05, 2020 at 11:42:46 -0500, Nicholas Jankowski wrote:
> It appears that at least
> currently, fplot in Octave cannot handle a symbolic function. (i did try
> with a simple polynomial function to verify it wasn't something unique to
> the function you used.)  I can't confirm whether or not this is a
> regression from a previous version of symbolic, but did confirm that Matlab
> 2019a is able to execute the same fplot command without issue.

Right, this has never worked in Octave's symbolic package.

'fplot' is listed as yet-to-be-implemented on this task list:

  https://github.com/cbm755/octsympy/issues/215

Also already reported here:

  https://savannah.gnu.org/bugs/?57382

--
mike



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem symbolic on windows

DigitalHermit
In reply to this post by nrjank
Try something like:

fcn=(inline("13*x-heaviside(x-2)*15*(x-2)-heaviside(x-4)*9*(x-4)^2/2"))
ezplot(fcn(x), [0,6]);





--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Problem symbolic on windows

Stef Pillaert
This post was updated on .
hmmm... when I use the ezplot-solution, won't I loose all the benefits of
symbolic calculation? E.g., in my script, I calculate twice the integral of M(x) to get z(x), and I want to plot z(x) in the end.
The goal of the script is that a user only has to change the definiton of M(x) to find the plot of the resulting z(x)

Stef



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Problem symbolic on windows

Colin Macdonald-2
In reply to this post by DigitalHermit
On 2020-02-06 1:54 a.m., DigitalHermit wrote:
> Try something like:
>
> fcn=(inline("13*x-heaviside(x-2)*15*(x-2)-heaviside(x-4)*9*(x-4)^2/2"))
> ezplot(fcn(x), [0,6]);

If you have a symbolic expression, you can often use "function_handle"
to convert it to Octave expression.

 >> syms x
 >> f = 13*x-heaviside(x-2)*15*(x-2)
 >> h = function_handle(f, 'vars', x)
 >> ezplot(h)

Something like that anyway, try "help @sym/function_handle" for examples
and details.

Colin


Reply | Threaded
Open this post in threaded view
|

Re: Problem symbolic on windows

DigitalHermit
In reply to this post by Stef Pillaert
Stef Pillaert wrote
> hmmm... when I use the ezplot-solution, won't I loose all the benefits of
> symbolic calculation? E.g., in my script, I calculate twice the integral
> of M(x) to get z(x), and I want to plot z(x) in the end.
> The goal of the script is that a user only has to change the definiton of
> M(x) to find the plot of the resulting z(x)

 Apologies, I was only looking at getting past that first class error which
I'd experienced with something similar, and specifically only at the
graphing aspect. You do lose some benefits, though the suggestion of
function_handle looks to be cleaner.

  I just a moment ago tried it in Octave 5.1.0 and Matlab 2019b. The first
subplot does work and are similar, but I'm getting Python errors around the
solve(). Do you recall what version it worked on previously?







--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Problem symbolic on windows

Stef Pillaert
DigitalHermit wrote
>   I just a moment ago tried it in Octave 5.1.0 and Matlab 2019b. The first
> subplot does work and are similar, but I'm getting Python errors around
> the
> solve(). Do you recall what version it worked on previously?

Hmm... does the first fplot work for you, then? In my original version? Or
are you using some ezplot-variant?
(To be honest, after al the help/feedback I'm getting from this extremely
helpfull forum, I 'm more and more in doubt if my original script actually
ever worked in octave, ...)



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html