Sharedlab3.ipynbOpen in CoCalc
function y=fun1(x)
    y=sin(x).^3;
end
x=-3.*pi:0.01:3.*pi;
y=fun1(x);
plot(x,y)
title('y=sin(x).^3 (A. Hryshchenko )')
xlabel('x')
ylabel('y')
x=-3.*pi:0.01:3.*pi;
b=[1 2 3];
y=fun1(x);
subplot(1 2 3);
plot(x,y)
title('y=sin(b.*x) (A. Hryshchenko )')
xlabel('x')
ylabel('y')
parse error: syntax error >>> subplot(1 2 3); ^
 function y=fun2(x,b)
    y=sin(b.*x);
end

x=-3.*pi:0.01:3.*pi;
y1=fun2(x,1);
y2=fun2(x,2);
y3=fun2(x,3);
plot(x,y1, x,y2, x,y3)
title('y=sin(b.*x) (A. Hryshchenko)')
xlabel('x')
ylabel('y')
legend('b=1','b=2','b=3')
subplot(3,1,1)
plot(x,y1)
title('y=sin(b.*x) (A. Hryshchenko)')
subplot(3,1,2)
plot(x,y2)
title('y=sin(b.*x) (A. Hryshchenko)')
subplot(3,1,3)
plot(x,y3)
title('y=sin(b.*x) (A. Hryshchenko)')
function y=fun3(x,b,a)
    y=a.*sin(b.*x);
end
x=-3.*pi:0.01:3.*pi;
y1=fun3(x,1,1);
y2=fun3(x,1,2);
y3=fun3(x,1,10);
plot(x,y1, x,y2, x,y3)
title('y=a.*sin(b.*x) (A. Hryshchenko)')
xlabel('x')
ylabel('y')
legend('a=1','a=2','a=10')
subplot(3,1,1)
plot(x,y1)
ylim([-10 10])
title('y=a.*sin(b.*x) (A. Hryshchenko)')
subplot(3,1,2)
plot(x,y2)
ylim([-10 10])
title('y=a.*sin(b.*x) (A. Hryshchenko)')
subplot(3,1,3)
plot(x,y3)
ylim([-10 10])
title('y=a.*sin(b.*x) (A. Hryshchenko)')

function y=fun4(x,c,z)
    y=c.*x.^z;
end
x=0:0.01:3;
y1=fun4(x,1,0.1);
y2=fun4(x,1,0.2);
y3=fun4(x,1,0.4);
y4=fun4(x,1,0.5);
plot(x,y1, x,y2, x,y3, x,y4)
title('y=c.*x.^z (A. Hryshchenko)')
xlabel('x')
ylabel('y')
legend('z=0.1','z=0.2','z=0.4','z=0.5')
subplot(4,1,1)
plot(x,y1)
title('y=c.*x.^z (A. Hryshchenko)')
subplot(4,1,2)
plot(x,y2)
title('y=c.*x.^z (A. Hryshchenko)')
subplot(4,1,3)
plot(x,y3)
title('y=c.*x.^z (A. Hryshchenko)')
subplot(4,1,4)
plot(x,y4)
title('y=c.*x.^z (A. Hryshchenko)')
a=[11 12 13;14 15 16;17 18 19];
size(a)
ans = 3 3
a=[11 12 13;14 15 16;17 18 19];
b=zeros(3,3)
numel(a)
b = 0 0 0 0 0 0 0 0 0 ans = 9
a=[11 12 13;14 15 16;17 18 19];
a(:)=25
a = 25 25 25 25 25 25 25 25 25
a=[11 12 13;14 15 16;17 18 19];
N=numel(a)
for k=1:N
a(k)=25;
end
numel(a)
N = 9 ans = 9
function y=f(x)
    y=x.*0.1
end
x=11:1:14
y=x.*0.1;
plot(x,y,'r*')
x = 11 12 13 14
x=11:1:14
y=x.*0.1;
y2=y;
y2(x>12)=5;
plot(x,y)
hold on
plot(x,y2,'g*')
x = 11 12 13 14
function y=f(x)
    y=zeros(size(x));
    y(x>2)=1;
    y(x<=2)=2;
end
x=0:0.01:4;
y=f(x)
plot(x,y)
y = Columns 1 through 20: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 21 through 40: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 41 through 60: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 61 through 80: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 81 through 100: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 101 through 120: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 121 through 140: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 141 through 160: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 161 through 180: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 181 through 200: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Columns 201 through 220: 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 221 through 240: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 241 through 260: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 261 through 280: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 281 through 300: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 301 through 320: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 321 through 340: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 341 through 360: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 361 through 380: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 381 through 400: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Column 401: 1
function y=f(x)
    y=zeros(size(x));
    y(x<20)=1;
    y(20<=x & x<30)=3;
    y(30<=x)=2;
end
x=10:0.01:40;
y=f(x);
plot(x,y)
ylim([0 4])