Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %plik nazwać fun
- function y=fun(x, T, y1, y2, y3, y4)
- r = rem(x,T)/T;
- if (r < 1/4)
- y=y1(x);
- elseif (r <1/2)
- y=y2(x);
- elseif (r <3/4)
- y=y3(x);
- else
- y=y4(x);
- end
- end
- ----------
- %zad.3
- clc; clear; close all;
- x=0:0.01:10;
- T=ones(1,length(x)).*10;
- y1=@(x) cos(x);
- y2=@(x) sin(x);
- y3=@(x) x.^(0.12);
- y4=@(x) 2*x;
- %figure(1)
- % subplot(4,1,1); plot(x, arrayfun(@fun, x, T, y1, y2, y3, y4));
- % %subplot(4,1,2); plot(x,y,'r-');
- y=[];
- for i=1:length(x)
- y=[y, fun(x(i), T, y1, y2, y3, y4)];
- end
- figure(1)
- subplot(3,1,1); plot(x,y,'r-');
- subplot(6,1,3); plot(x,arrayfun(y1, x),'r-');
- subplot(6,1,4); plot(x,arrayfun(y2, x),'r-');
- subplot(6,1,5); plot(x,arrayfun(y3, x),'r-');
- subplot(6,1,6); plot(x,arrayfun(y4, x),'r-');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement