还是matlab画图问题,要输入一个变量的
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/12 06:24:46
还是matlab画图问题,要输入一个变量的
clc; clear all;
h=input('h=');
y=zeros(1,30000);
r=zeros(1,30000);
for i=1:30000
r(i) = unifrnd(0,1);
y(i)=h*tan(pi*(r(i)-0.5));
end;
x=y(y>-30&y Untitled at 2
syms h x
画不出来图啊
clc; clear all;
h=input('h=');
y=zeros(1,30000);
r=zeros(1,30000);
for i=1:30000
r(i) = unifrnd(0,1);
y(i)=h*tan(pi*(r(i)-0.5));
end;
x=y(y>-30&y Untitled at 2
syms h x
画不出来图啊
你可以这样写程序:
clc; clear all;
syms h x
h=input('h=');
y=zeros(1,30000);
r=zeros(1,30000);
for i=1:30000
r(i) = unifrnd(0,1);
y(i)=h*tan(pi*(r(i)-0.5));
end;
x=y(y>-30&y<30);
n=hist(x,20)
hist(x,20)
hold on;
x=-30:0.1:30;
plot(x,30000*h./(pi*(x.*x+h*h)),'r')
clc; clear all;
syms h x
h=input('h=');
y=zeros(1,30000);
r=zeros(1,30000);
for i=1:30000
r(i) = unifrnd(0,1);
y(i)=h*tan(pi*(r(i)-0.5));
end;
x=y(y>-30&y<30);
n=hist(x,20)
hist(x,20)
hold on;
x=-30:0.1:30;
plot(x,30000*h./(pi*(x.*x+h*h)),'r')