声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1356|回复: 11

[编程技巧] 高手进来看看哈~~

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

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

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

x
L1=1000;
L2=1100;
W1=200;
W2=200;
d=1500;
l=(d-L1):min(sqrt(L2^2+W2^2/4),L1+d)
thet1=acos((L1^2+d^2-l^2)/2*L1*d);
thet2u=acos((L1^2+l^2-d^2)/2*L1*l)+asin((W2/2*l)-3.14);
thet2l=acos((L1^2+l^2-d^2)/2*L1*l)-asin((W2/2*l)-3.14);
plot(thet1,thet2u);
hold on;
plot(thet1,thet2l);
怎么编译总出错呀

[ 本帖最后由 cozy 于 2006-9-22 13:59 编辑 ]
回复
分享到:

使用道具 举报

发表于 2006-9-22 10:55 | 显示全部楼层
建议阅读最基本的matlab语法,了解.*与*的区别
 楼主| 发表于 2006-9-22 14:07 | 显示全部楼层
L1=1000;
L2=1100;
W1=200;
W2=200;
d=1500;
l=(d-L1):min(sqrt(L2^2+W2^2/4),L1+d)
thet1=acos((L1^2+d^2-l.^2)/2*L1*d);
thet2u=acos((L1^2+l^2-d^2)/2*L1*.l)+asin((W2/2*.l)-3.14);
thet2l=acos((L1^2+l^2-d^2)/2*L1*.l)-asin((W2/2*.l)-3.14);
plot(thet1,thet2u);
hold on;
plot(thet1,thet2l);
这样还是不行呀~~
发表于 2006-9-22 14:20 | 显示全部楼层
继续认真修改吧
发表于 2006-9-22 15:49 | 显示全部楼层
好好看书,打好基础
 楼主| 发表于 2006-9-22 18:28 | 显示全部楼层
我是菜鸟
谢谢大家的鼓励啊
发表于 2006-9-22 19:06 | 显示全部楼层
哈哈
八 就是出手不凡
直击要点~~
发表于 2006-9-22 19:14 | 显示全部楼层
thet1=acos((L1^2+d^2-l^2)/2*L1*d);此句L1,d 都是scalar,而l 是vector,不可以这样运算的,注意试用点乘和矩阵乘法的区别。此处你完全可以用循环来表达的,当然要注意thet1最好用数组存储了
发表于 2006-9-22 19:39 | 显示全部楼层
原帖由 stoney696 于 2006-9-22 19:14 发表
thet1=acos((L1^2+d^2-l^2)/2*L1*d);此句L1,d 都是scalar,而l 是vector,不可以这样运算的,注意试用点乘和矩阵乘法的区别。此处你完全可以用循环来表达的,当然要注意thet1最好用数组存储了



不建议使用循环,好不容易出现像楼主那样使用向量、矩阵的表达形式,当然要鼓励啦,继续加油~~~~~注意是.*,不是*.,认真阅读最基础的matlab语法。

[ 本帖最后由 eight 于 2006-9-22 19:41 编辑 ]
 楼主| 发表于 2006-9-24 10:21 | 显示全部楼层
close all
clc
clear all
L1=1000;
L2=1100;
W1=200;
W2=200;
d=1500;
l=(d-L1):round(min(sqrt(L2^2+W2^2/4),L1+d));
thet1=imag(acos((L1.^2+d.^2-l.^2)/2*L1.*d));
thet2u=imag(acos((L1.^2+l.^2-d.^2)/2*L1.*l)+asin((W2/2.*l)-3.14));
thet2l=imag(acos((L1.^2+l.^2-d.^2)/2*L1.*l)-asin((W2/2.*l)-3.14));
plot(thet1,thet2u);
hold on;
plot(thet1,thet2l);  
可以编译成功,但不知道为什么和预想的曲线相差太大
发表于 2006-9-24 10:50 | 显示全部楼层
原帖由 cozy 于 2006-9-24 10:21 发表
close all
clc
clear all
L1=1000;
L2=1100;
W1=200;
W2=200;
d=1500;
l=(d-L1):round(min(sqrt(L2^2+W2^2/4),L1+d));
thet1=imag(acos((L1.^2+d.^2-l.^2)/2*L1.*d));
thet2u=imag(acos((L1.^2+l.^2-d. ...



自己调试一下吧,这种事情除了你知道实际效果以外,没人知道。是否分母忘记加括号了?
发表于 2006-9-24 16:32 | 显示全部楼层
好好的修改把!!!根本就是错的吗
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-5-4 16:05 , Processed in 0.072214 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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