Guest User

Untitled

a guest
Apr 30th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.00 KB | None | 0 0
  1. function uplowH(fun,a,b,n,hObject)
  2.  
  3. handles=guidata(hObject);
  4. t=[a:0.01:b];
  5. f=fun(t);
  6.  
  7. axes(handles.upper);hold off;plot(t,f,'LineWidth',2);hold on; axis tight; title('Sumy górne');
  8. axes(handles.lower);hold off;plot(t,f,'LineWidth',2);hold on; axis tight; title('Sumy dolne');
  9.  
  10.  
  11. d=(b-a)/n;
  12. valLOW=0;
  13. valUP=0;
  14. P=[a:d:b];
  15. Q=fun(P);
  16. size(P);
  17.  
  18. axes(handles.upper);
  19. for i=1:n
  20.     x=[P(i),P(i+1),P(i+1),P(i)];
  21.     temp=fun([P(i):0.01:P(i+1)]);
  22.     maxV=max(temp);
  23.     y=[0,0,maxV,maxV];
  24.    
  25.     fill(x,y,'r','FaceAlpha', 0.4);
  26.     valUP=valUP+d*maxV;
  27. end    
  28.     set(handles.UPval,'String',num2str(valUP,'%.4f'))
  29.  
  30.     axes(handles.lower);
  31. for i=1:n
  32.     %pause(0.001);
  33.     x=[P(i),P(i+1),P(i+1),P(i)];
  34.     temp=fun([P(i):0.01:P(i+1)]);
  35.     minV=min(temp);
  36.     y=[0,0,minV,minV];
  37.    
  38.     fill(x,y,'g','FaceAlpha', 0.4);
  39.     valLOW=valLOW+d*minV;
  40.    
  41. end
  42.     set(handles.LOWval,'String',num2str(valLOW,'%.4f'))
  43.  
  44.  
  45.  
  46.  
  47. axes(handles.lower); hold off
  48. axes(handles.upper); hold off
  49. end
Advertisement
Add Comment
Please, Sign In to add comment