comparison scripts/general/interp1.m @ 20038:9fc020886ae9

maint: Clean up m-files to follow Octave coding conventions. Try to trim long lines to < 80 chars. Use '##' for single line comments. Use '(...)' around tests for if/elseif/switch/while. Abut cell indexing operator '{' next to variable. Abut array indexing operator '(' next to variable. Use space between negation operator '!' and following expression. Use two newlines between endfunction and start of %!test or %!demo code. Remove unnecessary parens grouping between short-circuit operators. Remove stray extra spaces (typos) between variables and assignment operators. Remove stray extra spaces from ends of lines.
author Rik <rik@octave.org>
date Mon, 23 Feb 2015 14:54:39 -0800
parents 4197fc428c7d
children
comparison
equal deleted inserted replaced
20037:a1acca0c2216 20038:9fc020886ae9
558 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps) 558 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
559 %!assert (isempty (interp1 (xp',yp',[],style))) 559 %!assert (isempty (interp1 (xp',yp',[],style)))
560 %!assert (isempty (interp1 (xp,yp,[],style))) 560 %!assert (isempty (interp1 (xp,yp,[],style)))
561 %!assert (interp1 (xp,[yp',yp'],xi(:),style),... 561 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
562 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) 562 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
563 # %!assert (interp1 (xp,yp,xi,style),... 563 #%!assert (interp1 (xp,yp,xi,style),...
564 # %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) 564 #%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
565 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), 565 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
566 %! interp1 (xp,yp,xi,style,"extrap"),10*eps) 566 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
567 %!error interp1 (1,1,1, style) 567 %!error interp1 (1,1,1, style)
568 ## ENDBLOCK 568 ## ENDBLOCK
569 569
576 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps) 576 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
577 %!assert (isempty (interp1 (xp',yp',[],style))) 577 %!assert (isempty (interp1 (xp',yp',[],style)))
578 %!assert (isempty (interp1 (xp,yp,[],style))) 578 %!assert (isempty (interp1 (xp,yp,[],style)))
579 %!assert (interp1 (xp,[yp',yp'],xi(:),style),... 579 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
580 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) 580 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
581 # %!assert (interp1 (xp,yp,xi,style),... 581 #%!assert (interp1 (xp,yp,xi,style),...
582 # %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) 582 #%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
583 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), 583 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
584 %! interp1 (xp,yp,xi,style,"extrap"),10*eps) 584 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
585 %!error interp1 (1,1,1, style) 585 %!error interp1 (1,1,1, style)
586 %!assert (interp1 (xp,[yp',yp'],xi,style), 586 %!assert (interp1 (xp,[yp',yp'],xi,style),
587 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps) 587 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
593 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps) 593 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
594 %!assert (isempty (interp1 (xp',yp',[],style))) 594 %!assert (isempty (interp1 (xp',yp',[],style)))
595 %!assert (isempty (interp1 (xp,yp,[],style))) 595 %!assert (isempty (interp1 (xp,yp,[],style)))
596 %!assert (interp1 (xp,[yp',yp'],xi(:),style),... 596 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
597 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) 597 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
598 # %!assert (interp1 (xp,yp,xi,style),... 598 #%!assert (interp1 (xp,yp,xi,style),...
599 # %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) 599 #%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
600 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), 600 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
601 %! interp1 (xp,yp,xi,style,"extrap"),10*eps) 601 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
602 %!error interp1 (1,1,1, style) 602 %!error interp1 (1,1,1, style)
603 ## ENDBLOCK 603 ## ENDBLOCK
604 604
778 778
779 ## Left and Right discontinuities 779 ## Left and Right discontinuities
780 %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "right"), [-2,0.5,4,3,1.5]) 780 %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "right"), [-2,0.5,4,3,1.5])
781 %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "left"), [-2,0.5,1,3,1.5]) 781 %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "left"), [-2,0.5,1,3,1.5])
782 782
783 %% Test input validation 783 ## Test input validation
784 %!error interp1 () 784 %!error interp1 ()
785 %!error interp1 (1,2,3,4,5,6,7) 785 %!error interp1 (1,2,3,4,5,6,7)
786 %!error <minimum of 2 points required> interp1 (1,1,1, "linear") 786 %!error <minimum of 2 points required> interp1 (1,1,1, "linear")
787 %!error <minimum of 2 points required> interp1 (1,1,1, "*nearest") 787 %!error <minimum of 2 points required> interp1 (1,1,1, "*nearest")
788 %!error <minimum of 2 points required> interp1 (1,1,1, "*linear") 788 %!error <minimum of 2 points required> interp1 (1,1,1, "*linear")