3 // Copyright (C) INRIA - Masoud Najafi <masoud.najafi@inria.fr>
4 // Serge Steer <serge.steer@inria.fr> 1993
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 // See the file ../license.txt
24 function [x,y,typ]=CURVE_c(job,arg1,arg2)
25 //** 07/01/2008 : Adapted fot Scilab 5.0 by Simone Mannori
36 graphics = arg1.graphics;
37 exprs = graphics.exprs;
43 [ok,Method,xx,yy,PeriodicOption,graf,exprs] = scicos_getvalue("Spline data",["Spline"+...
44 " Method (0..7)";"x";"y";"Periodic signal(y/n)?";"Launch"+...
45 " graphic window(y/n)?"],list("vec",1,"vec",-1, ...
46 "vec",-1,"str",1,"str",1),exprs)
51 if PeriodicOption=="y" | PeriodicOption=="Y" then
57 if graf=="y" | graf=="Y" then
73 METHOD = getmethod(mtd);
80 if ~((nx==ny)&(mx==my)) then
81 messagebox("Incompatible size of [x] and [y]","modal","error");
86 if ~Ask_again then //+++++++++++++++++++++++++++++++++++++++
88 [xy] = cleandata(xy); // just for sorting to be able to compare data before and after poke_point(.)
90 exprs(5)="n";// exprs.graf='n'
92 if gui then //_______Graphic editor___________
96 if (winsid() == []) then
99 curwin = max(winsid())+1; //** prepare a brand new win
101 //** see below in this file; "poke_point" is very similar to "edit_curv"
102 [orpar,oipar,ok] = poke_point(xy,ipar,rpar); //** HERE WE ARE +++++++++++++++++++++++++++++++++++
105 end;// exit without save
107 // verifying the data change
109 xy2=[orpar(1:N2),orpar(N2+1:2*N2)];
110 New_methhod=oipar(2);
112 METHOD=getmethod(New_methhod);
113 if or(xy(:,1)<>xy2(:,1)) then,
116 if or(xy(1:N-1,2)<>xy2(1:N2-1,2)) then,
119 if (xy(N,2)<>xy2(N2,2) & (METHOD<>"periodic")) then,
123 exprs(2)=strcat(sci2exp(xy2(:,1)))
124 exprs(3)=strcat(sci2exp(xy2(:,2)))
127 exprs(1)=sci2exp(New_methhod);
135 else//_____________________No graphics__________________________
136 [Xdummy,Ydummy,orpar]=Do_Spline(N,mtd,xy(:,1),xy(:,2));
137 if (METHOD=="periodic") then // periodic spline
140 if (METHOD=="order 2" | METHOD=="not_a_knot"|METHOD=="periodic" | METHOD=="monotone"| METHOD=="fast" | METHOD=="clamped") then
141 orpar=[xy(:,1);xy(:,2);orpar];
143 if (METHOD=="zero order"|METHOD=="linear")
144 orpar=[xy(:,1);xy(:,2);]
147 exprs(1)=sci2exp(mtd);// pour le cas methode>7 | method<0
150 end //___________________________________________________________
151 end //++++++++++++++++++++++++++++++++++++++++++++++++++++++
154 xp=find(orpar(1:oipar(1))>=0);
156 model.firing=orpar(xp(1)); //first positive event
162 graphics.exprs=exprs;
176 model.sim=list("curve_c",4)
179 model.rpar=[xx(:);yy(:)]
180 model.ipar=[N;Method;1]
186 exprs=[sci2exp(Method);sci2exp(xx);sci2exp(yy);PeriodicOption;Graf]
189 x=standard_define([2 2],model,exprs,gr_i)
194 function [rpar,ipar,ok] = poke_point(ixy,iparin,rparin)
198 //** get_click is already defined in "editi_curv"
199 //in line definition of get_click
200 deff("[btn,xc,yc,win,Cmenu]=get_click(flag)",[
201 "if ~or(winsid() == curwin) then Cmenu = ''Quit'';return,end,";
202 "if argn(2) == 1 then";
203 " [btn, xc, yc, win, str] = xclick(flag);";
205 " [btn, xc, yc, win, str] = xclick();";
207 "if btn == -1000 then";
208 " if win == curwin then";
209 " Cmenu = ''Quit'';";
211 " Cmenu = ''Open/Set'';";
217 " try " // added to handle unwanted menu actions in french version
218 " execstr(''Cmenu='' + part(str, 9:length(str) - 1));";
219 " execstr(''Cmenu='' + Cmenu);";
232 if size(xy,"c")<2 then
233 gcf().info_message = " No [y] is provided";
237 [xy] = cleandata(ixy)
244 ipar = [N;NOrder;PeridicOption]
249 PeridicOption = iparin(3);
255 PeridicOption = iparin(3);
267 Sin_exprs = list(string(Amp),string(wp), string(phase),string(offset),string(np1));
271 Sawt1_exprs = list(string(sAmp),string(sTp),string(sdelay));
274 Sawt2_exprs = list(string(sAmp2),string(sTp2));
281 Pulse_exprs=list(string(Amp3), string(Tp3),string(Pw3),string(Pd3),string(Bias3))
288 random_n_exprs=list(string(mean4),string(var4), string(seed4),string(sample4),string(np4))
295 random_u_exprs=list(string(min5), string(max5), string(seed5),string(sample5),string(np5))
297 // bornes initiales du graphique
317 rect = [xmn,ymn;xmx,ymx];
325 menu_o = ["zero order","linear","order 2","not_a_knot","periodic","monotone","fast","clamped"]
326 menu_d = ["Clear","Data Bounds","Load from text file","Save to text file","Load from Excel","Periodic signal"]
327 menu_t=["sine","sawtooth1","sawtooth2","pulse","random normal","random uniform"]
328 menu_e=["Help","Exit without save","Save/Exit"]
329 MENU=["Autoscale","Spline","Data","Standards","Exit"];
330 menus = list(MENU,menu_s,menu_o,menu_d,menu_t,menu_e);
335 Orderm=w(ones(menu_o))+string(1:size(menu_o,"*"))+r(ones(menu_o))
338 Datam=w(ones(menu_d))+string(1:size(menu_d,"*"))+r(ones(menu_d))
341 Standm=w(ones(menu_t))+string(1:size(menu_t,"*"))+r(ones(menu_t))
344 Exitm=w(ones(menu_e))+string(1:size(menu_e,"*"))+r(ones(menu_e))
346 execstr("Autoscale_"+string(curwin)+"=scam")
347 execstr("Spline_"+string(curwin)+"=Orderm")
348 execstr("Data_"+string(curwin)+"=Datam")
349 execstr("Standards_"+string(curwin)+"=Standm")
350 execstr("Exit_"+string(curwin)+"=Exitm")
352 addmenu(curwin,MENU(1))
353 addmenu(curwin,MENU(2),menu_o)
354 addmenu(curwin,MENU(3),menu_d)
355 addmenu(curwin,MENU(4),menu_t)
356 addmenu(curwin,MENU(5),menu_e)
357 //===================================================================
361 a.data_bounds = rect;
362 a.axes_visible = "on";
364 xtitle( "", "time", "Output" ) ;
366 a.title.font_style=4;
367 a.title.foreground=2;
370 xpolys(xy(:,1),xy(:,2),[-1]); //children(2)
371 xpolys(xy(:,1),xy(:,2),[5]); //children(1)
372 splines = a.children(1).children
373 points = a.children(2).children
374 //---------------------------------------
375 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
377 // -- boucle principale
380 while %t then //=================================================
382 [btn,xc,yc,win,Cmenu] = get_click(); //** see
383 if ((win>0) & (win<>curwin)) then
384 Cmenu="Mouse click is Offside!";
389 if (Cmenu=="Exit") |(Cmenu=="Quit" ) then,
395 //-------------------------------------------------------------------
396 if ((Cmenu=="zero order") | (Cmenu=="linear") | (Cmenu=="order 2")| ...
397 (Cmenu=="not_a_knot")| (Cmenu=="periodic")| (Cmenu=="monotone")| ...
398 (Cmenu=="fast")| (Cmenu=="clamped")) then
401 case "zero order" then
407 case "not_a_knot" then
419 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
421 //-------------------------------------------------------------------
423 case "Data Bounds" then
425 [mok, xmn1, xmx1, ymn1, ymx1] = scicos_getvalue("Enter new bounds",["xmin";"xmax"; "ymin";"ymax"], ..
426 list("vec", 1,"vec", 1,"vec", 1,"vec", 1), string(rectx(:)))
429 if (xmn1 > xmx1 | ymn1 > ymx1) then
430 gcf().info_message = "Incorrect bounds"
434 gcf().info_message = "X should be positive"
438 a.data_bounds=[xmn1, ymn1; xmx1, ymx1];
442 //-------------------------------------------------------------------
443 case "Autoscale" then
444 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
445 //-------------------------------------------------------------------
446 case "Periodic signal" then
447 if PeridicOption==1 then,
452 [mok,myans]=scicos_getvalue("Generating periodic signal",["y/n"],list("str",1),list(ans0));
453 if ((myans=="y")|(myans=="Y")) then,
458 ipar(3)=PeridicOption;
459 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
460 //-------------------------------------------------------------------
462 [mok,Amp,wp,phase,offset,np1,Sin_exprs2]=scicos_getvalue(" Sine parameters", ...
463 ["Amplitude";"Frequency(rad/sec)"; ...
464 "Phase(rad)";"Bias";"number of points"],list("vec",1,"vec",1,"vec",1, ...
465 "vec",1,"vec",1),Sin_exprs)
472 phase=atan(tan(phase));
473 xt=linspace(0,%pi*2/wp,np1)';
474 yt=Amp*sin(wp*xt+phase)+offset;
476 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
479 //-------------------------------------------------------------------
480 case "sawtooth1" then
481 [mok,sAmp,sTp,sdelay,Sawt1_exprs2]=scicos_getvalue("Sawtooth signal parameters", ...
482 ["Amplitude";"Period";"delay"], ...
483 list("vec",1,"vec",1,"vec",1),Sawt1_exprs)
495 [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
496 Sawt1_exprs=Sawt1_exprs2
498 //-------------------------------------------------------------------
499 case "sawtooth2" then
500 [mok,sAmp2,sTp2,Sawt2_exprs2]=scicos_getvalue("Sawtooth signal parameters", ...
501 ["Amplitude";"Period"],list("vec",1,"vec",1),Sawt2_exprs)
508 [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
509 Sawt2_exprs=Sawt2_exprs2
511 //-------------------------------------------------------------------
513 [mok,Amp3,Tp3,Pw3,Pd3,Bias3,Pulse_exprs2] = scicos_getvalue("Square wave pulse signal", ...
514 ["Amplitude";"Period (sec)";"Pulse width(% o"+...
515 "f period)";"Phase delay (sec)";"Bias"],list("vec",1, ...
516 "vec",1,"vec",1,"vec",1,"vec",1),Pulse_exprs);
527 //otherwise there would be double points at 0
530 xt=[xt;Pd3; Pw3*Tp3/100+Pd3;Tp3];
531 yt=[yt;Amp3+Bias3;Bias3;Bias3];
533 xt=[0;Tp3];yt=[Bias3;Bias3];
536 xt=[0;Tp3];yt=[Bias3;Bias3];
540 [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
541 Pulse_exprs=Pulse_exprs2;
543 //-------------------------------------------------------------------
544 case "random normal" then
545 [mok,mean4,var4,seed4,sample4,np4,random_n_exprs2]=scicos_getvalue("Normal (Gaussian) random signal", ...
546 ["Mean";"Variance";"Initial seed";"Sample time";"Number of points"],list("vec",1, ...
547 "vec",1,"vec",1,"vec", ...
548 1,"vec",1),random_n_exprs)
549 if mok & sample4>0 then
554 xt=0:sample4:sample4*(np4-1);
556 yt=mean4+sqrt(var4)*rand(np4,1);
558 [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
559 random_n_exprs2=random_n_exprs;
561 //-------------------------------------------------------------------
562 case "random uniform" then
563 [mok,min5,max5,seed5,sample5,np5,random_u_exprs2]=scicos_getvalue("Uniform random signal", ...
564 ["Minimum";"Maximum";"Initial seed";"Sample time";"Number of points"],list("vec",1, ...
565 "vec",1,"vec",1,"vec", ...
566 1,"vec",1),random_u_exprs)
567 if mok & sample5>0 then
572 xt=0:sample5:sample5*(np5-1);
574 yt=min5+(max5-min5)*rand(np5,1);
576 [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
577 random_u_exprs2=random_u_exprs;
580 //-------------------------------------------------------------------
581 case "Save/Exit" then
583 PeridicOption=ipar(3);
585 METHOD=getmethod(NOrder);
586 if (METHOD=="periodic") then // periodic spline
590 if (METHOD=="order 2" | METHOD=="not_a_knot"|METHOD=="periodic" | METHOD=="monotone"| METHOD=="fast" | METHOD=="clamped") then
591 rpar=[xy(:,1);xy(:,2);rpar];
593 if (METHOD=="zero order"|METHOD=="linear")
594 rpar=[xy(:,1);xy(:,2);]
601 //-------------------------------------------------------------------
602 case "Exit without save" then
608 //-------------------------------------------------------------------
613 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
614 //----------------------------------------------------------------
615 case "Edit text data NOT IN USE" then
617 [mok,xt,yt]=scicos_getvalue("Enter x and y data",["x";"y"],list("vec",-1,"vec",-1),list(strcat(sci2exp(xy(:,1))),strcat(sci2exp(xy(:,2)))));
621 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
623 //---------------------------------------------------------------
625 t1="Mouse-left click: adding a new point"
626 t2="Mouse-right click: remove a point"
627 t3="Mouse-left double click: edit a point''s coordinates"
628 t4="Mouse-left button press/drag/release: move a point"
629 t5="Change the window size: ''Data'' menu -> ''Databounds''"
630 messagebox([t1;t2;t3;t4;t5],"modal","info");
631 //---------------------------------------------------------------
632 case "Load from Excel" then
633 [tok,xytt]=ReadExcel()
638 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
640 //---------------------------------------------------------------
641 case "Load from text file" then
642 [tok,xytt]=ReadFromFile()
647 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
649 //---------------------------------------------------------------
650 case "Save to text file" then
652 //---------------------------------------------------------------
657 [rpar,ipar]=drawSplin(a,xy,ipar,rpar);
660 //----------------------------------------------------------
666 dist=((xt-ones(N,1)*xc))^2+((yt-ones(N,1)*yc))^2
669 ex=abs(rectx(2,1)-rectx(1,1))/80;
670 ey=abs(rectx(2,2)-rectx(1,2))/80;
671 if (abs(xc-xt(k))<ex & abs(yc-yt(k))<ey) then
676 //_________________________
677 // if ~((NOrder==-1|NOrder==-2|NOrder==-3|NOrder==-4)) then
678 if (~HIT)&(btn==0 | btn==3) then // add point
685 [xtt,k2]=gsort(xy(:,1),"r","i");xy=xy(k2,:)
688 [rpar,ipar]=drawSplin(a,xy,ipar,rpar);
693 if (HIT)&(btn==2 | btn==5) then // remove point
694 if (xy(k,1)>0) |( xy(k,1)==0 & (size(find(xy(:,1)==0),"*")>1)) then
699 [rpar,ipar] = drawSplin(a,xy,ipar,rpar);
703 if (HIT)&(btn==0) then // move point
704 [xy,rpar,ipar] = movept(a,xy,ipar,rpar,k)
707 if (HIT)&(btn==10) then // change data:: double click
708 [mok,xt,yt]=scicos_getvalue("Enter new x and y",["x";"y"],...
709 list("vec",1,"vec",1),list(sci2exp(xy(k,1)),sci2exp(xy(k,2))));
715 [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
721 //_________________________________
724 //----------------------------------------------------------
727 //========================================================================
728 function [orpar,oipar] = drawSplin(a,xy,iipar,irpar)
729 N=size(xy,"r");// new size of xy
732 points=a.children(2).children
733 splines=a.children(1).children
735 periodicoption=iipar(3);
738 METHOD=getmethod(order);
740 if periodicoption==1 then
741 PERIODIC="periodic, T="+string(x(N)-x(1));
743 PERIODIC="aperiodic";
745 a.title.text=[string(N)+" points, "+"Method: "+METHOD+", "+PERIODIC];
753 // NP=50;// number of intermediate points between two data points
754 [X,Y,orpar]=Do_Spline(N,order,x,y);
755 if (periodicoption==1) then
759 xmx=max(points.data(:,1)); xmn=min(points.data(:,1));
762 xmx1=max(a.x_ticks.locations)
767 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
769 oipar=[N;iipar(2);periodicoption]
771 //=============================================================
772 function [xyt,orpar,oipar]=movept(a,xy,iipar,irpar,k)
773 //on bouge un point existant
774 points=a.children(2).children
775 splines=a.children(1).children
795 while ~(btn==3 | btn==0| btn==10| btn==-5)
796 rep=xgetmouse([%t %t]); xc=rep(1);yc=rep(2);btn=rep(3);
811 [xt,k2]=gsort(xt,"r","i");yt=yt(k2)
816 [orpar,oipar]=drawSplin(a,xyt,oipar,orpar);
822 //==========================================================
823 function rectx = findrect(a)
824 splines=a.children(1).children
825 points=a.children(2).children
827 if (points.data==[]) then
833 ymx1=max(splines.data(:,2));
834 ymn1=min(splines.data(:,2))
836 xmx=max(points.data(:,1));
837 xmn=min(points.data(:,1));
838 ymx=max(points.data(:,2));
839 ymn=min(points.data(:,2));
858 rectx=[XMN,YMN;XMX,YMX];
861 //============================================================
862 function [tok,xyo]=ReadExcel()
863 TA=["A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P"; ...
864 "Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"a";"b";"c";"d";"e";"f"; ...
865 "g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v"; ...
867 TN=["0","1","2","3","4","5","6","7","8","9"];
871 [zok,filen,sheetN,xa,ya]=scicos_getvalue("Excel data file ",["Filename";"Sheet #"+...
872 " ";"X[start:Stop]";"Y[start:stop]"],list("str",1, ...
875 list(["Classeur1.xls"],["1"],["C5:C25"],["D5:D25"]));
881 [fd,SST,Sheetnames,Sheetpos] = xls_open(filen);
883 gcf().info_message = "Scicos cannot find the excel file:"+filen;
887 N=size(Sheetnames,"*");
888 if ((sheetN<=N) &(sheetN>0)) then
889 [Value,TextInd] = xls_read(fd,Sheetpos(sheetN))
892 xa=strsubst(xa," ","");
894 ya=strsubst(ya," ","");
897 x2=part(xa,px+1:length(xa));
899 y2=part(ya,py+1:length(ya));
901 x1p=min(strindex(x1,TN));
903 gcf().info_message = "Bad address in X:"+x1;
906 x11=part(x1,1:x1p-1);
907 x12=part(x1,x1p:length(x1));
909 x2p=min(strindex(x2,TN));
911 gcf().info_message = "Bad address in X:"+x2;
915 x22=part(x2,x2p:length(x2));
917 y1p=min(strindex(y1,TN));
919 gcf().info_message = "Bad address in Y:"+y1;
922 y11=part(y1,1:y1p-1);
923 y12=part(y1,y1p:length(y1));
925 y2p=min(strindex(y2,TN));
927 gcf().info_message = "Bad address in Y:"+y2;
930 y21=part(y2,1:y2p-1);
931 y22=part(y2,y2p:length(y2));
941 xstC=xstC+modulo(find(TA==part(x11,lx11-i+1)),26)*26^(i-1);
945 xenC=xenC+modulo(find(TA==part(x21,lx21-i+1)),26)*26^(i-1);
949 ystC=ystC+modulo(find(TA==part(y11,ly11-i+1)),26)*26^(i-1);
953 yenC=yenC+modulo(find(TA==part(y21,ly21-i+1)),26)*26^(i-1);
963 if ~(xstR<=mv & xstR>0 & xenR<=mv & xenR>0&ystR<=mv & ystR>0¥R<=mv¥R>0 ) then
964 gcf().info_message = "error in Row data addresses";
967 if ~(xstC<=nv & xstC>0 & xenC<=nv & xenC>0&ystC<=nv & ystC>0¥C<=nv¥C>0 ) then
968 gcf().info_message = "error in Column data addresses";
972 xo=Value(min(xstR,xenR):max(xstR,xenR),min(xstC,xenC):max(xstC,xenC));
973 yo=Value(min(ystR,yenR):max(ystR,yenR),min(ystC,yenC):max(ystC,yenC));
974 [nx,mx]=size(xo);// adjusting the x and y size
986 gcf().info_message = " Scicos cannot read your Excel file, please verify the parameters ";
992 //---------------------------------------------------------------
993 function [xyo]=cleandata(xye)
997 [nx,mx]=size(xe);// adjusting the x and y size
1003 // checking for NULL data
1005 if (xe(i)<>xe(i)) then
1006 gcf().info_message = "x contains no data:x("+string(i)+")";
1009 if (ye(i)<>ye(i)) then
1010 gcf().info_message = "Y contains no data:y("+string(i)+")";
1017 if (find(xe==0)==[]) then // add zero point
1022 [xo,k2]=gsort(xe,"r","i");
1027 //---------------------------------------------------------------
1028 function [orpar,oipar] = AutoScale(a,xy,inipar,inrpar)
1032 points = a.children(2).children
1033 splines = a.children(1).children
1036 [orpar,oipar] = drawSplin(a,xy,oipar,orpar);
1038 a.data_bounds = rectx;
1041 //============================
1042 function METHOD = getmethod(order)
1062 //=======================================
1063 function [sok,xye] = ReadFromFile()
1066 [sok,filen,Cformat,Cx,Cy]=scicos_getvalue("Text data file ",["Filename";"Reading [C] f"+...
1067 "ormat";"Abscissa column";"Output"+...
1068 " column"],list("str",1,"str",1,"vec",1,"vec",1), ...
1069 list(["mydatafile.dat"],["%g %g"],["1"],["2"]));
1073 px=strindex(Cformat,"%");
1076 gcf().info_message = "Bad format in reading data file";
1082 fd=mopen(filen,"r");
1083 Lx=mfscanf(-1,fd,Cformat);
1086 gcf().info_message = "Scicos cannot open the data file: " + filen;
1091 if ((mD==0) | (nD==0)) then,
1092 gcf().info_message = "No data read";
1097 gcf().info_message = "Bad format";
1105 [xye]=cleandata(xye)
1110 //=======================================
1111 function [sok]=SaveToFile(xye)
1116 [sok,filen,Cformat]=scicos_getvalue("Text data file ",["Filename";"Writing [C] f"+...
1117 "ormat"],list("str",1,"str",1), ...
1118 list(["mydatafile.dat"],["%g %g"]));
1122 px=strindex(Cformat,"%");
1125 gcf().info_message = "Bad format in writing data file";
1130 Cformat=Cformat+"\n";
1133 fd=mopen(filen,"w");
1134 mfprintf(fd,Cformat,xe,ye);
1137 gcf().info_message = "Scicos cannot open the data file:" + filen;
1145 //=========================================================
1146 function [X,Y,orpar]=Do_Spline(N,order,x,y)
1151 METHOD=getmethod(order);
1153 if (METHOD=="zero order") then
1157 X=[X;x(i);x(i+1);x(i+1)];
1158 Y=[Y;y(i);y(i);y(i+1)];
1162 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1163 if (METHOD=="linear") then
1171 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1190 X=[X;linspace(x(i),x(i+1),NP+2)']; // pour tous sauf "linear" et "zero order"
1192 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1193 if (N>2) & (METHOD=="order 2") then
1205 Y(j)=A(i)*(X(j)-x(i))^2+B(i)*(X(j)-x(i))+C(i);
1207 orpar=matrix(Z,-1,1)
1209 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1210 if (METHOD=="not_a_knot") then
1212 d = splin(x, y, METHOD);
1213 Y = interp(X, x, y, d);
1217 gcf().info_message = "ERROR in SPLINE: "+METHOD
1219 messagebox(lasterror(), "ERROR in SPLINE: "+METHOD);
1224 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1225 if (METHOD=="periodic") then
1230 d = splin(x, y,METHOD);
1231 Y = interp(X, x, y, d);
1235 gcf().info_message = "ERROR in SPLINE: "+METHOD
1237 messagebox(lasterror(), "ERROR in SPLINE: "+METHOD);
1241 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1242 if (METHOD=="monotone" ) then
1244 d = splin(x, y, METHOD);
1245 Y = interp(X, x, y, d);
1249 gcf().info_message = "ERROR in SPLINE: "+METHOD
1251 messagebox(lasterror(), "ERROR in SPLINE: "+METHOD);
1256 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1257 if (METHOD=="fast") then
1259 d = splin(x, y, METHOD);
1260 Y = interp(X, x, y, d);
1264 gcf().info_message = "ERROR in SPLINE: "+METHOD
1266 messagebox(lasterror(), "ERROR in SPLINE: "+METHOD);
1270 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1271 if (METHOD=="clamped") then
1273 d = splin(x, y, METHOD,[0;0]);
1274 Y = interp(X, x, y, d);
1278 gcf().info_message = "ERROR in SPLINE: "+METHOD
1280 messagebox(lasterror(), "ERROR in SPLINE: "+METHOD);
1286 //=================================================
1287 function [Z]=ORDER2(x,y)
1295 A(j+1,i)=(x(i+1)-x(i))^2;
1296 A(j+1,i+N)=x(i+1)-x(i);
1303 A(j+2,i)=2*(x(i+1)-x(i));
1310 Q(i,i)=4*(x(i+1)-x(i))^2
1311 Q(i,i+N)=2*(x(i+1)-x(i))
1312 Q(i+N,i)=2*(x(i+1)-x(i))
1316 At=[Q,A';A,zeros(3*N-1,3*N-1)]
1321 //===================================================