Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function uplowH(fun,a,b,n,hObject)
- handles=guidata(hObject);
- t=[a:0.01:b];
- f=fun(t);
- axes(handles.upper);hold off;plot(t,f,'LineWidth',2);hold on; axis tight; title('Sumy górne');
- axes(handles.lower);hold off;plot(t,f,'LineWidth',2);hold on; axis tight; title('Sumy dolne');
- d=(b-a)/n;
- valLOW=0;
- valUP=0;
- P=[a:d:b];
- Q=fun(P);
- size(P);
- axes(handles.upper);
- for i=1:n
- x=[P(i),P(i+1),P(i+1),P(i)];
- temp=fun([P(i):0.01:P(i+1)]);
- maxV=max(temp);
- y=[0,0,maxV,maxV];
- fill(x,y,'r','FaceAlpha', 0.4);
- valUP=valUP+d*maxV;
- end
- set(handles.UPval,'String',num2str(valUP,'%.4f'))
- axes(handles.lower);
- for i=1:n
- %pause(0.001);
- x=[P(i),P(i+1),P(i+1),P(i)];
- temp=fun([P(i):0.01:P(i+1)]);
- minV=min(temp);
- y=[0,0,minV,minV];
- fill(x,y,'g','FaceAlpha', 0.4);
- valLOW=valLOW+d*minV;
- end
- set(handles.LOWval,'String',num2str(valLOW,'%.4f'))
- axes(handles.lower); hold off
- axes(handles.upper); hold off
- end
Advertisement
Add Comment
Please, Sign In to add comment