24小时热门版块排行榜    

查看: 807  |  回复: 5
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

qq449077540

新虫 (初入文坛)

[交流] 【求助】画图中的legend问题 已有3人参与

syms x % k=6
x=0:0.001:0.11
y=50/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.15*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.44*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+50/119232*(cosh(6*x).*cos(6*x)-1)%-4*50*6/119232*0.25*(cosh(6*(x-0.11)).*sin(6*(x-0.11))-sinh(6*(x-0.11)).*cos(6*(x-0.11)))
plot(x,y)
hold on
x=0.11:0.001:0.33
y=50/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.15*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.44*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+50/119232*(cosh(6*x).*cos(6*x)-1)-4*50*6/119232*0.25*(cosh(6*(x-0.11)).*sin(6*(x-0.11))-sinh(6*(x-0.11)).*cos(6*(x-0.11)))
plot(x,y)
hold on
syms x % k=6
x=0:0.001:0.22
y=237/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.11*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.13*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+237/119232*(cosh(6*x).*cos(6*x)-1)%-4*50*6/119232*0.25*(cosh(6*(x-0.22)).*sin(6*(x-0.22))-sinh(6*(x-0.22)).*cos(6*(x-0.22)))
plot(x,y)
hold on
x=0.22:0.001:0.33
y=237/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.11*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.13*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+237/119232*(cosh(6*x).*cos(6*x)-1)-4*50*6/119232*0.25*(cosh(6*(x-0.22)).*sin(6*(x-0.22))-sinh(6*(x-0.22)).*cos(6*(x-0.22)))
plot(x,y)
hold on
legend('23','23','56','56')


通过分段函数现2条直线,然后legend一下,前两个函数需要用一个名称,后两个用一个名称。
但是,我得到却是 一个函数一个名称
求助大伙帮个忙,谢谢啦
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

change0618

铁杆木虫 (著名写手)

方丈大师

★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
robert2020(金币+2):好方法!呵呵... 2010-07-16 23:38:25
用判断的形式把分段函数弄成一个形式
y=func1*(x>=0 & x<=0.11)+func2*(x>0.11 & x<0.33)
3楼2010-07-16 23:17:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 6 个回答

qq449077540

新虫 (初入文坛)

2楼2010-07-16 21:31:16
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

robert2020

银虫 (著名写手)


小木虫(金币+0.5):给个红包,谢谢回帖交流
楼主在使用plot然后hold on以后实际上画出了四条曲线,而hold on后plot默认的曲线颜色为blue(故而四条曲线显示均为blue),legend一般用法是对所用的曲线进行标注。依据楼主编程要求修改如下:
引用回帖:
syms x % k=6
x=0:0.001:0.11;
y=50/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.15*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.44*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+50/119232*(cosh(6*x).*cos(6*x)-1);%-4*50*6/119232*0.25*(cosh(6*(x-0.11)).*sin(6*(x-0.11))-sinh(6*(x-0.11)).*cos(6*(x-0.11)))
H(1)=plot(x,y,'blue');
hold on
x=0.11:0.001:0.33;
y=50/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.15*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.44*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+50/119232*(cosh(6*x).*cos(6*x)-1)-4*50*6/119232*0.25*(cosh(6*(x-0.11)).*sin(6*(x-0.11))-sinh(6*(x-0.11)).*cos(6*(x-0.11)));
H(2)=plot(x,y,'blue');
hold on
syms x % k=6
x=0:0.001:0.22;
y=237/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.11*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.13*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+237/119232*(cosh(6*x).*cos(6*x)-1);%-4*50*6/119232*0.25*(cosh(6*(x-0.22)).*sin(6*(x-0.22))-sinh(6*(x-0.22)).*cos(6*(x-0.22)))
H(3)=plot(x,y,'red');
hold on
x=0.22:0.001:0.33;
y=237/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.11*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+0.13*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+237/119232*(cosh(6*x).*cos(6*x)-1)-4*50*6/119232*0.25*(cosh(6*(x-0.22)).*sin(6*(x-0.22))-sinh(6*(x-0.22)).*cos(6*(x-0.22)));
H(4)=plot(x,y,'red');
hold on
legend(H([1,3]),'23','56')

图形如下:
引用回帖:
Originally posted by qq449077540 at 2010-07-16 21:29:27:
syms x % k=6
x=0:0.001:0.11
y=50/119232*(-0.81*0.5*(cosh(6*x).*sin(6*x)+sinh(6*x).*cos(6*x))+2.73*0.25*(cosh(6*x).*sin(6*x)-sinh(6*x).*cos(6*x)))+4*50*6/119232*(-0.15*0.5*(cosh(6*x).*sin(6*x)+sin ...

Truthfulness,Compassion,Tolerance,Beauty
4楼2010-07-16 23:31:57
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

qq449077540

新虫 (初入文坛)

引用回帖:
Originally posted by change0618 at 2010-07-16 23:17:39:
用判断的形式把分段函数弄成一个形式
y=func1*(x>=0 & x<=0.11)+func2*(x>0.11 & x<0.33)

谢谢啦,能不能用您的方法把我的问题写一下,不太明白
5楼2010-07-17 13:06:40
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 08工科 320总分 求调剂 +6 梨花珞晚风 2026-03-17 6/300 2026-03-21 03:40 by JourneyLucky
[考研] 307求调剂 +3 wyyyqx 2026-03-17 3/150 2026-03-21 03:20 by JourneyLucky
[考研] 085700资源与环境308求调剂 +12 墨墨漠 2026-03-18 13/650 2026-03-21 01:42 by JourneyLucky
[考研] 280求调剂 +7 咕噜晓晓 2026-03-18 8/400 2026-03-21 01:27 by JourneyLucky
[考研] 265求调剂 +12 梁梁校校 2026-03-19 13/650 2026-03-20 21:01 by 无际的草原
[考研] 0817 化学工程 299分求调剂 有科研经历 有二区文章 +22 rare12345 2026-03-18 22/1100 2026-03-20 20:39 by zhukairuo
[考研] 一志愿西安交通大学 学硕 354求调剂 +3 我想要读研究生 2026-03-20 3/150 2026-03-20 20:13 by JourneyLucky
[基金申请] 学校已经提交到NSFC,还能修改吗? 40+4 babangida 2026-03-19 8/400 2026-03-20 15:58 by babero
[考研] 材料学硕318求调剂 +5 February_Feb 2026-03-19 5/250 2026-03-19 23:51 by 23Postgrad
[考研] 材料考研调剂 +3 xwt。 2026-03-19 3/150 2026-03-19 11:22 by w沐阳w
[考研] 0817调剂 +3 没有答案_ 2026-03-14 3/150 2026-03-19 09:51 by Xu de nuo
[考研] 化学工程321分求调剂 +15 大米饭! 2026-03-15 18/900 2026-03-18 14:52 by haxia
[考研] 311求调剂 +11 冬十三 2026-03-15 12/600 2026-03-18 14:36 by 星空星月
[考博] 26博士申请 +3 1042136743 2026-03-17 3/150 2026-03-17 23:30 by 轻松不少随
[考研] 301求调剂 +4 A_JiXing 2026-03-16 4/200 2026-03-17 17:32 by ruiyingmiao
[考研] 考研化学学硕调剂,一志愿985 +4 张vvvv 2026-03-15 6/300 2026-03-17 17:15 by ruiyingmiao
[考研] [导师推荐]西南科技大学国防/材料导师推荐 +3 尖角小荷 2026-03-16 6/300 2026-03-16 23:21 by 尖角小荷
[考研] 318求调剂 +3 Yanyali 2026-03-15 3/150 2026-03-16 16:41 by houyaoxu
[考研] 288求调剂 +4 奇点0314 2026-03-14 4/200 2026-03-14 23:04 by JourneyLucky
[考研] 297一志愿上交085600求调剂 +5 指尖八千里 2026-03-14 5/250 2026-03-14 17:26 by a不易
信息提示
请填处理意见