clear all
clc
a=10
b=4
% a=1 b=2 c=3
type=input('type','s')
x=input ('x=')
switch lower(type)
case ('1')
if x>2
f=x^2+2*x
elseif x<2
f=x^2
else x=2
f=40
end
case '2'
if x>8
f=a+b
elseif x<8
f=a*x^2
else f=100
end
end
clear all
clc
x=[1 2 3 4]
y=[5 6 7 8]
p=polyfit(x,y,2)
y2=polyval(p,x)
e=abs(y-y2)
plot(x,y,'r*')
hold on
plot(x,e,'b')
hold on
plot(x,y2,'g')
clear all
clc
% x=input('x=')
a=input('a=')
% b=input('b=')
r=ones(1,120)*a
teta=0:pi/119:pi
polar(teta,r)
hold on
a=10
r=ones(1,120)*a
teta=-pi:pi/119:0
polar(teta,r)
یا می توانیم به صورت زیر بنویسیم
clear all
clc
% x=input('x=')
a=input('a=')
% b=input('b=')
r=ones(1,120)*a
teta=0:2*pi/119:2*pi
polar(teta,r)