题目一
clear all
close all
clc
a=input('请输入数字a');
b=input('请输入数字b');
if a>b
max_num=a;
else
max_num=b;
end
disp('两个数字中大的那个是')
max=max_num
题目2
function [S, D]=area(r)
S=pi*r*r;
D=2*pi*r;
命令中输入
[s d]=area(5);就可以了 5可以换成别的!
题目三
clear all
close all
clc
t=linspace(-pi,pi,1000);
y1=sin(t);
y2=cos(t);
plot(t,y1,':r',t,y2,'*b')
title('正弦曲线和余弦曲线');
xlabel('t的变换情况')
ylabel('sin(t)和cos(t)随t的变化')
legend('sin(t)','cos(t)')
grid on;
figure(2)
subplot(1,2,1)
plot(t,y1)
subplot(1,2,2)
plot(t,y2)
figure(3)
plot(t,y1)
figure(4)
plot(t,y2)
matlab的输入输出很少用,太坑了!!!一时间有点忘记了!