Re: [Scilab-users] Avoiding a loop

2017-05-10 Thread Samuel Gougeon

Le 10/05/2017 à 17:25, Frieder Nikolaisen a écrit :


There was a piece of code missing:

P  =  [
1,   0;  
2,   50;  
5,   110;

10,  80;
11,  200
15,  0];

batt  =  1000;
gen  =  0;

n  =  1
for  n=1:5

 if  P(n,2)  >  100  then
 if  batt  >  800  then  batt  =  batt  -  P(n,2)  *  (P(n+1,1)  -  
P(n,1))
 else
 gen  =  gen  +  P(n,2)  *  (P(n+1,1)  -  P(n,1))
 end
 
 else

 batt  =  batt  -  P(n,2)  *  (P(n+1,1)  -  P(n,1))
 end
disp('n '  +  string(n))
disp('batt '  +  string(batt))
disp('gen '  +  string(gen))
end

Am 2017-05-10 17:23, schrieb Frieder Nikolaisen:


Hello,

I did write an example code, but I do not like the time consuming way 
I solved the problem. With 50 000 lines in the matrix, it wouldn't be 
fun.


How can I avoid using the for-loop?

10,  80;
11,  200
15,  0];

batt  =  1000;
gen  =  0;

n  =  1
for  n=1:5

 if  P(n,2)  >  100  then
 if  batt  >  800  then  batt  =  batt  -  P(n,2)  *  (P(n+1,1)  -  
P(n,1))
 else
 gen  =  gen  +  P(n,2)  *  (P(n+1,1)  -  P(n,1))
 end
 
 else

 batt  =  batt  -  P(n,2)  *  (P(n+1,1)  -  P(n,1))
 end
disp('n '  +  string(n))
disp('batt '  +  string(batt))
disp('gen '  +  string(gen))
end


It may be compacted with:

P  =  [1.2.   5.   10. 11. 15.
0.50.   110.80.200.0.  ]';
batt  =  1000;
gen  =  0;
terms  =  P(1:$-1,2)  .*  (P(2:$,1)  -  P(1:$-1,1));
for  n = 1:5
if  P(n,2)  <=  100  |  batt   >  800  then
batt  =  batt  -  terms(n);
else
gen  =  gen  +  terms(n);
end mprintf("n = %d batt = %d gen = %d\n", n, batt, gen);
end

Then, as told by Tim, since the condition on batt may change batt 
according to n,

it is hard to go on without the loop.

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] applying a function to each element

2017-05-10 Thread Samuel Gougeon

Le 10/05/2017 à 21:36, Erhy a écrit :

in this special task it is a good practice.
Generally I wished to have a similar notation as in C  or java (logical) ? a
: b
Is there a built in function to have such conditionals ?

Example:

--> format(6)
--> a = rand(3,4)
 a  =
   0.362   0.483   0.502   0.633
   0.292   0.332   0.437   0.405
   0.566   0.594   0.269   0.918

--> c = a< 0.5
 c  =
  T T F F
  T T T T
  F F T F

--> a(c) = 0
 a  =
   0.  0.  0.502   0.633
   0.  0.  0.  0.
   0.566   0.594   0.  0.918


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] applying a function to each element

2017-05-10 Thread Erhy
in this special task it is a good practice.
Generally I wished to have a similar notation as in C  or java (logical) ? a
: b
Is there a built in function to have such conditionals ?
Erhy



--
View this message in context: 
http://mailinglists.scilab.org/Scilab-users-applying-a-function-to-each-element-tp4036347p4036359.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Avoiding a loop

2017-05-10 Thread Amanda Osvaldo
What it's the equation you need to compute ?Perhaps I can help.
I think it's possible to compute with something in this way:
map = find (P(:,2) > 100 );
if batt > 800 then
batt = batt - P(map,2) * (P(map+1,1) - P(map,1));
end

On Wed, 2017-05-10 at 17:23 +0200, Frieder Nikolaisen wrote:
> Hello,
> 
> I did write an example code, but I do not like the time consuming way
> I solved the problem. With 50 000 lines in the matrix, it wouldn't be
> fun.
> 
> How can I avoid using the for-loop?
> 
> 10, 80;
> 11, 200
> 15, 0];
> 
> batt = 1000;
> gen = 0;
> 
> n = 1
> for n=1:5
> 
> if P(n,2) > 100 then
> if batt > 800 then batt = batt - P(n,2) * (P(n+1,1) - P(n,1))
> else
> gen = gen + P(n,2) * (P(n+1,1) - P(n,1))
> end
> 
> else
> batt = batt - P(n,2) * (P(n+1,1) - P(n,1))
> end
> disp('n ' + string(n))
> disp('batt ' + string(batt))
> disp('gen ' + string(gen))
> end
> 
> 
> Thanks alot!
> 
> 
> 
> Best regards
> Frieder 
> 
>  
> 
> 
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Problem installing Image Processing Toolbox

2017-05-10 Thread AliZ
Great, that makes sense. Thanks a lot!



--
View this message in context: 
http://mailinglists.scilab.org/Problem-installing-Image-Processing-Toolbox-tp4036334p4036351.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] applying a function to each element

2017-05-10 Thread Frieder Nikolaisen
 

Hello Samuel, 

thanks a lot. It works fine. 

Best regards
Frieder


Am 2017-05-10 13:33, schrieb sgoug...@free.fr: 

> Hello Frieder,
> 
>
max(A,B) does it:
> --> max(A,B)
> ans =
> 3.
> 3.
> 2.
> 
> Samuel
> 
>
- Mail original -
> 
> Hello, 
> 
> I have to matrices: A = [ 1
; 2 ; 2 ] B = [ 3 ; 3 ; 1 ] 
> 
> I looking for get matric with having
only the larger Elemtns: 
> 
> C = [ 3 ; 3 ; 2 ] 
> Is there function to
make to apply functions to eacth element. 
> 
> C = [ if A .> B then A
else B] elemtwise. 
> 
> A for loop is to slow. 
> 
> Thanks a lot. 
>

> Cheers 
> Frieder 
>
___
> users mailing list
>
users@lists.scilab.org
>
http://lists.scilab.org/mailman/listinfo/users

 ___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Problems with figures in Scilab 6.0.0

2017-05-10 Thread sgougeon
Hello Philippe,

Could you provide compared parts of screenshots from 5.5.2 and from 6.0.0 
illustrating it at the same resolution?
(whole heavy screenshots are not necessarily required)
Thanks

Samuel

- Mail original -
Hi,

My name is Philippe, I work in the field of physics and signal processing, I 
use scilab a lot in my work and I want to thanks very much all the the people 
involve in the development of this great software. 

  I updated my scilab to 6.0.0 two weeks ago on my power book (retina) running 
macOS 10.12.4. Since this time I experiment two problems with graphic figures. 
The first issue is that the thickness of the lines is really small and the text 
for the axis labels, curves label and title are almost unreadable (way smaller 
than in the preceding version). The second problem is about the zoom, when I 
try to zoom on a graphic figure using the rectangular selection with the mouse, 
I get an offset between the mouse pointer and the actual selection, making it 
impossible to correctly define de rectangular region. 

Is anybody else experimenting the same issues ? Does somebody have a fix or a 
workaround for that ?

Philippe.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] applying a function to each element

2017-05-10 Thread sgougeon
Hello Frieder,

max(A,B) does it:
--> max(A,B)
 ans  =
   3.
   3.
   2.

Samuel

- Mail original -

Hello, 

I have to matrices: A = [ 1 ; 2 ; 2 ] B = [ 3 ; 3 ; 1 ] 

I looking for get matric with having only the larger Elemtns: 

C = [ 3 ; 3 ; 2 ] 
Is there function to make to apply functions to eacth element. 

C = [ if A .> B then A else B] elemtwise. 

A for loop is to slow. 

Thanks a lot. 

Cheers 
Frieder 
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Problems with figures in Scilab 6.0.0

2017-05-10 Thread Philippe DÉROGIS
Hi,

My name is Philippe, I work in the field of physics and signal processing, I 
use scilab a lot in my work and I want to thanks very much all the the people 
involve in the development of this great software. 

  I updated my scilab to 6.0.0 two weeks ago on my power book (retina) running 
macOS 10.12.4. Since this time I experiment two problems with graphic figures. 
The first issue is that the thickness of the lines is really small and the text 
for the axis labels, curves label and title are almost unreadable (way smaller 
than in the preceding version). The second problem is about the zoom, when I 
try to zoom on a graphic figure using the rectangular selection with the mouse, 
I get an offset between the mouse pointer and the actual selection, making it 
impossible to correctly define de rectangular region. 

Is anybody else experimenting the same issues ? Does somebody have a fix or a 
workaround for that ?

Philippe.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Clear, export only an axis

2017-05-10 Thread Samuel Gougeon

Hello Alexx,

Le 10/05/2017 à 08:56, Alexx a écrit :

Thank you Samuel,

good idea to copy the axis into a new figure, i could do what I 
wanted. I just turn the new figure invisible to make the process 
transparent for the user. We can see the new figure opening and 
closing right away (seeable no more than 0.3s). Nevertheless, I didn't 
succes in doing the contrary, that's to say to copy a whole figure 
containing only one axis into a frame which occupies a part of a figure.


You may try to copy only the axes. A whole figure can't be a child of a 
frame, but an axes can.


Best regards
Samuel

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Clear, export only an axis

2017-05-10 Thread Alexx
Thank you Samuel,

good idea to copy the axis into a new figure, i could do what I wanted. 
I just turn the new figure invisible to make the process transparent for 
the user. We can see the new figure opening and closing right away 
(seeable no more than 0.3s). Nevertheless, I didn't succes in doing the 
contrary, that's to say to copy a whole figure containing only one axis 
into a frame which occupies a part of a figure.

Anyway, it's good to have new tracks!
Have a good day


Le 04/05/2017 à 01:53, Samuel GOUGEON [via Scilab / Xcos - Mailing Lists 
Archives] a écrit :
> Hello,
>
> >Is it possible, when many axes (plot2d or polarplot) are docked into 
> a unique figure,
>
> You mean: when using subplot()? Then, we do not properly speak about 
> "docking".
> Figures that are really docked together or to the desktop remain 
> separated.
>
> >to export the PNG of an axis like with the xs2png() function
> >and a figure, without exporting the whole figure?
>
> AFAIK, it is not possible. Exports apply only to whole figures.
> But you may copy() an axes alone into a new figure, and then export 
> this one.
>
>
> >Also, is it possible to clear only one axis which is contained into a 
> figure
> >without clearing the whole figure?
> Yes, with
> delete(handle_of_the_axes)
>
> HTH
> Samuel
> ___
> users mailing list
> [hidden email] 
> http://lists.scilab.org/mailman/listinfo/users
>
>
> 
> If you reply to this email, your message will be added to the 
> discussion below:
> http://mailinglists.scilab.org/Clear-export-only-an-axis-tp4036294p4036298.html
>  
>
> To unsubscribe from Clear, export only an axis, click here 
> .
> NAML 
> 
>  
>





--
View this message in context: 
http://mailinglists.scilab.org/Clear-export-only-an-axis-tp4036294p4036342.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users