[Scilab-users] A generic datastructure dump tool? message 4 of 20)

scilab.20.browseruk at xoxy.net scilab.20.browseruk at xoxy.net
Wed Mar 30 08:24:52 CEST 2016


Claus,

Tim got it right.

When you plot 2d data, you supply two (matching) vectors of (in my case) simple reals.

Inside the figure, the resulting polyline stores the same data as matrix of pairs (points).

In order to manipulate the figure by delving inside and adjusting that polyline data I need to construct an equivalent matrix of pairs from two vectors of reals. Be a neophyte with Scilab and similar languages, more used to more traditional programming languages, I was using a for loop; but I was aware there was probably a better way.

With Tim's information, I was able to work out through trial and error that [ x' y' ] give me the data in the form that the polyline uses internally.

eg.
-->a = 1:10
 a  =   1.    2.    3.    4.    5.    6.    7.    8.    9.    10.  
 
-->b = a.^(1/9)
 b  =   1.    1.0800597    1.129831    1.166529    1.1958132    1.2202849    1.2413658    1.259921    1.276518    1.2915497  
 
-->plot( a, b );
-->f = gcf();
-->p = f.children.children.children;
-->p.data
 ans  =
    1.     1.         
    2.     1.0800597  
    3.     1.129831   
    4.     1.166529   
    5.     1.1958132  
    6.     1.2202849  
    7.     1.2413658  
    8.     1.259921   
    9.     1.276518   
    10.    1.2915497  
 
-->c = [ a' b' ]
 c  =
    1.     1.         
    2.     1.0800597  
    3.     1.129831   
    4.     1.166529   
    5.     1.1958132  
    6.     1.2202849  
    7.     1.2413658  
    8.     1.259921   
    9.     1.276518   
    10.    1.2915497  

Get's a bit messier when there are mutliple lines on the graph; and handles have a tendency to go out of scope , but that's the essence of it.

Buk

> -----Original Message-----
> From: scilab.browseruk.b507695203.cfuttrup#gmail.com at ob.0sg.net
> Sent: Tue, 29 Mar 2016 22:13:14 +0200
> To: users at lists.scilab.org
> Subject: Re: [Scilab-users] A generic datastructure dump tool? > message 4 of 20)
> 
> Hi Buk
> 
> Tim Wescott gave you the normal answers. I wonder what you're asking ...
> 
> If you have vector x = [2 3 4] and also a vector y = [2 3 4]
> You can calculate vector c = x .* y  (= [4 9 16] ... just as an example)
> Then you can place the values of c into the diagonal matrix M = diag(c)
> 
> ... (?) ... so is the answer to your question M = diag(x .* y) ... ?
> 
> ... or are x and y supposed to be real and imaginary numbers?
> 
> Sorry for my confusion about your question.
> 
> Best regards,
> Claus
> 
> On 29-03-2016 21:32, scilab.20.browseruk at xoxy.net wrote:
>>> After getting the handle PL of your polyline, you can directly update
>>> its points through PL.data
>>> Then, the graphics is directly updated. You don't need to redraw it
>>> with plot() ot plot2d().
>>> HTH
>>> Samuel
>> Thanks Samuel, that works brilliantly. The re-draw is so fast I had to
>> insert a sleep( 10 ) between iterations.
>> 
>> A follow up question (assuming that isn't breaking the list rules).
>> 
>> Is there a better way than using a for loop to map two vectors x, y to a
>> matrix ( [x1,y1],[x2,y2], ... )?
>> 
>> Cheers, Buk.
>> 
>> ____________________________________________________________
>> Can't remember your password? Do you need a strong and secure password?
>> Use Password manager! It stores your passwords & protects your account.
>> Check it out at http://mysecurelogon.com/manager
>> 
>> 
>> 
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>> 
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
Check it out at http://www.inbox.com/marineaquarium






More information about the users mailing list