[Scilab-users] Plot a function that contains matrix operations

Mathieu Dubois mathieu.dubois at limsi.fr
Thu Nov 29 23:17:20 CET 2012


Hello,

I don't know what you want to model exactly but there are several 
problems in your code.

In scilab, if x is a vector, Smat*x means matrix multiplication. As 
Smat is a 5x5 matrix it certainly won't work with a 96 components 
vector.
If x is a scalar it is the scalar multiplication  (better written 
x*Smat).
The expression initv*expm(x*Smat)*S0vec (for a scalar x) works. Is that 
what you want to compute?

If you want to plot a function you should have a look at the fplot 
function.

You will find attached a simple script that produce a graph very 
similar to the one you send.

HTH,
Mathieu

Le 29/11/2012 17:55, Svenja Lagershausen a écrit :
> Dear users,
>
> I would like to plot a function f(x) that contains matrix operations.
> Correctly, it looks like this (obtained by Mathematica):
>
>
>
> Do you know how to do this?
>
> My code is:
>
> ///Löschen der Variablen/
>
> clear
>
> ///Bereinigen der Konsole/
>
> clc
>
> /// S. Lagershausen/
>
> /// 2//9.11.2012/
>
> /// System : M = 3, n = 3, Expo -  vtlte Bz., mu1 = 0.7, mu2 = 0.5, 
> mu3
> = 0.9/
>
> /// E[TBPS] = 2.59664365/
>
> /// CV[TBPS] = 0.908682321/
>
> /// Daten der Verteilung der Zeit zw. Bearbeitungsbeginnzeitpunkten 
> an
> Station 1 :/
>
> initv= {1 0 0 0 0}
>
> Smat= [-0.7 0.061984965 0 0.111572936 0.200831285;
>
> 0-1.4 0.5 0 0;
>
> 00 -0.9 0 0;
>
> 00.5 0 -1.4 0;
>
> 00 0 0.5 -0.5]
>
> onevec= {1 1 1 1 1}
>
> S0vec= {0.325610814; 0.9; 0.9; 0.9; 0}
>
> /// Dichtefunktion :/
>
> _scf_(1);///create figure  1/
>
> _clf_(1);///clear figure 1/
>
> x=[1: 0.2 : 20]
>
> //x=2
>
> /////x= linspace(0,20,101);/
>
> ///temp1=Smat*x/
>
> ///f_x= sum(sum(Smat*x,"c"),"r")///
>
> ///test=Smat*(x);/
>
> f_x=initv*expm(Smat*x)*S0vec
>
> ///f_x=x/
>
> ////
>
> _plot_(x,f_x)
>
> /////xlabel('x'), ylabel('f(x)')/
>
> ///title('Dichtefunktion von TBPS')/
>
> ///Generating function of the PH renewal process/
>
> ///P_Stern=exp((Smat + z*S0vec*initv)*x)/
>
> x is the variable. If I simply plug in a single value, it works (the
> result is a value)
>
> However, if I I declare a range, it does not work anymore 
> (“Inconsitent
> multiplication”)
> I suppose that Scilab understands the range of x as a vector such 
> that
> the matrix operations cannot work that way.
>
> Thank you very much for your help!
>
> Best regards
> Svenja Lagershausen
>
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_svenja.sce
Type: application/x-scilab
Size: 531 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20121129/fa1cfd56/attachment.bin>


More information about the users mailing list