24小时热门版块排行榜    

查看: 804  |  回复: 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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 299求调剂 +6 △小透明* 2026-03-17 6/300 2026-03-21 02:42 by JourneyLucky
[考研] 278求调剂 +6 烟火先于春 2026-03-17 6/300 2026-03-21 01:57 by JourneyLucky
[考研] 一志愿西南交大,求调剂 +5 材化逐梦人 2026-03-18 5/250 2026-03-21 00:26 by JourneyLucky
[考研] 南京大学化学376求调剂 +3 hisfailed 2026-03-19 6/300 2026-03-20 23:43 by hisfailed
[考研] 一志愿南京理工大学085701资源与环境302分求调剂 +4 葵梓卫队 2026-03-18 6/300 2026-03-20 23:02 by JourneyLucky
[考研] 考研调剂求学校推荐 +3 伯乐29 2026-03-18 5/250 2026-03-20 22:59 by JourneyLucky
[考研] 350求调剂 +5 weudhdk 2026-03-19 5/250 2026-03-20 22:04 by luoyongfeng
[考研] 求调剂一志愿南京航空航天大学289分 +3 @taotao 2026-03-19 3/150 2026-03-20 21:34 by JourneyLucky
[考研] 一志愿 南京航空航天大学大学 ,080500材料科学与工程学硕 +5 @taotao 2026-03-20 5/250 2026-03-20 20:16 by JourneyLucky
[考研] 0856调剂,是学校就去 +8 sllhht 2026-03-19 9/450 2026-03-20 14:25 by 无懈可击111
[考研] 招收调剂硕士 +4 lidianxing 2026-03-19 12/600 2026-03-20 12:25 by lidianxing
[考研] 材料学硕318求调剂 +5 February_Feb 2026-03-19 5/250 2026-03-19 23:51 by 23Postgrad
[考研] 一志愿中国海洋大学,生物学,301分,求调剂 +5 1孙悟空 2026-03-17 6/300 2026-03-19 23:46 by zcl123
[考研] 320求调剂0856 +3 不想起名字112 2026-03-19 3/150 2026-03-19 22:53 by 学员8dgXkO
[考研] 一志愿天津大学化学工艺专业(081702)315分求调剂 +11 yangfz 2026-03-17 11/550 2026-03-19 15:06 by houyaoxu
[考研] 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
[硕博家园] 湖北工业大学 生命科学与健康学院-课题组招收2026级食品/生物方向硕士 +3 1喜春8 2026-03-17 5/250 2026-03-17 17:18 by ber川cool子
[考研] 考研化学学硕调剂,一志愿985 +4 张vvvv 2026-03-15 6/300 2026-03-17 17:15 by ruiyingmiao
[考研] 304求调剂 +5 素年祭语 2026-03-15 5/250 2026-03-16 17:00 by 我的船我的海
信息提示
请填处理意见