3-1
>> y=inline('sin(x)/(1+3*x+x^2)','x')
y =
内联函数:
y(x) = sin(x)/(1+3*x+x^2)
>> y(0)
ans =
0
>> y(pi/2)
ans =
0.1223
3-2
function y=z(x1,x2,x3)
y=x1^2+2*x2^2+3*x3^2+2*x1*x2+3*x2*x3+5*x2*x3;
在命令窗口输入
>> z(2,3,4)
ans =
178
3-3
3-4
a=input('请输入一个矩阵');
b=max(max(a));
c=min(min(a));
fprintf('最大值为%d,最小值为%d\n',b,c);
disp('最大值下标为');
[row,col]=find(a==b)
disp('最小值下标为');
[row,col]=find(a==c)
在命令窗口输入:
>> max_
请输入一个矩阵[4 5 6
7 8 9
10 11 12]
最大值为12,最小值为4
最大值下标为
row =
3
col =
3
最小值下标为
row =
1
col =
1