声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 915|回复: 4

[编程技巧] 请帮我修改一下程序

[复制链接]
发表于 2006-11-15 10:37 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=imread('tu2.bmp');
I=double(a);
n=20;
total1=0;
total2=0;
R=100;

for t=0:pi/30:2*pi;;
   
for i=0:n-1;
    x=R*i*cos(t)/n;
    y=R*i*sin(t)/n;
    x=round(x);
    y=round(y);
   
    up=I(x+128,y+128).*sin(2*pi*i/n);
   down=I(x+128,y+128).*cos(2*pi*i/n);
   total1=up+total1;
   total2=down+total2;
end
putha=atan(total1/total2);
end
plot(t,putha)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
我想画出(t,putha)的曲线图,却只得到一个点,如何才能画出曲线啊。

图a

图a
回复
分享到:

使用道具 举报

发表于 2006-11-15 10:43 | 显示全部楼层
原帖由 seavy 于 2006-11-15 10:37 发表
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=imread('tu2.bmp');
I=double(a);
n=20;
total1=0;
total2=0;
R=100;

for t=0:pi/30:2*pi;;
   
for i=0:n-1;
    x=R*i*cos(t)/n;
    y=R*i*sin(t)/n;
    x= ...


建议补补matlab的基础知识(相对于你写的循环条件),还有其他编程语言例如C语言什么都好(相对于你写的循环体)
 楼主| 发表于 2006-11-15 10:47 | 显示全部楼层
没那么多精力啊,凑合着用就行了,这个程序我运行没错误,就是画不出图形啊,小改一下能运行出来不
发表于 2006-11-15 11:05 | 显示全部楼层
原帖由 seavy 于 2006-11-15 10:47 发表
没那么多精力啊,凑合着用就行了,这个程序我运行没错误,就是画不出图形啊,小改一下能运行出来不



这年头,每个人都很忙,呵呵。建议用数组实现
发表于 2006-11-15 13:43 | 显示全部楼层
a=imread('tu2.bmp');
I=double(a);
n=20;
total1=0;
total2=0;
R=100;

for t=0:pi/30:2*pi;;
   
for i=0:n-1;
    x=R*i*cos(t)/n;
    y=R*i*sin(t)/n;
    x=round(x);
    y=round(y);
   
    up=I(x+128,y+128).*sin(2*pi*i/n);
   down=I(x+128,y+128).*cos(2*pi*i/n);
   total1=up+total1;
   total2=down+total2;
putha=atan(total1/total2);
plot(t,putha)
hold on
end
end
未命名.JPG
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-25 01:19 , Processed in 0.066520 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表