24小时热门版块排行榜    

查看: 805  |  回复: 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的回帖

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的回帖
查看全部 6 个回答

qq449077540

新虫 (初入文坛)

2楼2010-07-16 21:31:16
已阅   回复此楼   关注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的回帖

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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 324分 085600材料化工求调剂 +4 llllkkkhh 2026-03-18 4/200 2026-03-21 01:24 by JourneyLucky
[考研] 311求调剂 +5 冬十三 2026-03-18 5/250 2026-03-21 00:16 by JourneyLucky
[考研] 一志愿南京理工大学085701资源与环境302分求调剂 +4 葵梓卫队 2026-03-18 6/300 2026-03-20 23:02 by JourneyLucky
[考研] 324求调剂 +5 lucky呀呀呀鸭 2026-03-20 5/250 2026-03-20 22:30 by 促天成
[考研] 350求调剂 +5 weudhdk 2026-03-19 5/250 2026-03-20 22:04 by luoyongfeng
[考研] 中南大学化学学硕337求调剂 +3 niko- 2026-03-19 6/300 2026-03-20 21:58 by luoyongfeng
[考研] 353求调剂 +3 拉钩不许变 2026-03-20 3/150 2026-03-20 19:56 by JourneyLucky
[考研] 281求调剂(0805) +14 烟汐忆海 2026-03-16 25/1250 2026-03-20 15:47 by yuncha
[考研] 0856调剂,是学校就去 +8 sllhht 2026-03-19 9/450 2026-03-20 14:25 by 无懈可击111
[考研] 266求调剂 +5 阳阳哇塞 2026-03-14 10/500 2026-03-19 15:08 by 阳阳哇塞
[考研] 材料与化工求调剂 +7 为学666 2026-03-16 7/350 2026-03-19 14:48 by 尽舜尧1
[考研] 311求调剂 +11 冬十三 2026-03-15 12/600 2026-03-18 14:36 by 星空星月
[考研] 材料,纺织,生物(0856、0710),化学招生啦 +3 Eember. 2026-03-17 9/450 2026-03-18 10:28 by Eember.
[考研] 268求调剂 +6 简单点0 2026-03-17 6/300 2026-03-18 09:04 by 无际的草原
[考研] 326求调剂 +5 上岸的小葡 2026-03-15 6/300 2026-03-17 17:26 by ruiyingmiao
[考研] 有没有道铁/土木的想调剂南林,给自己招师弟中~ +3 TqlXswl 2026-03-16 7/350 2026-03-17 15:23 by TqlXswl
[考研] 一志愿南京大学,080500材料科学与工程,调剂 +4 Jy? 2026-03-16 4/200 2026-03-17 11:02 by gaoqiong
[考研] 一志愿211 0703方向310分求调剂 +3 努力奋斗112 2026-03-15 3/150 2026-03-16 16:44 by houyaoxu
[考研] 321求调剂 +5 大米饭! 2026-03-15 5/250 2026-03-16 16:33 by houyaoxu
[考研] 一志愿哈工大材料324分求调剂 +5 闫旭东 2026-03-14 5/250 2026-03-14 14:53 by 木瓜膏
信息提示
请填处理意见