24小时热门版块排行榜    

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

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的回帖

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的回帖

qq449077540

新虫 (初入文坛)

引用回帖:
Originally posted by robert2020 at 2010-07-16 23:31:57:
楼主在使用plot然后hold on以后实际上画出了四条曲线,而hold on后plot默认的曲线颜色为blue(故而四条曲线显示均为blue),legend一般用法是对所用的曲线进行标注。依据楼主编程要求修改如下:


图形如下:
...

非常感谢,方法很有效
6楼2010-07-17 13:07:20
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 学员hYBQgl 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 323求调剂 +3 洼小桶 2026-03-18 3/150 2026-03-20 22:54 by JourneyLucky
[考研] 287求调剂 +7 晨昏线与星海 2026-03-19 8/400 2026-03-20 22:19 by JourneyLucky
[考研] 材料与化工 322求调剂 +4 然11 2026-03-19 4/200 2026-03-20 22:12 by luoyongfeng
[考研] 290求调剂 +7 ^O^乜 2026-03-19 7/350 2026-03-20 21:43 by JourneyLucky
[考研] 260求调剂 +3 朱芷琳 2026-03-20 3/150 2026-03-20 20:35 by 学员8dgXkO
[考研] 289求调剂 +6 怀瑾握瑜l 2026-03-20 6/300 2026-03-20 20:30 by 学员8dgXkO
[考研] 环境工程调剂 +9 大可digkids 2026-03-16 9/450 2026-03-20 17:38 by 醉在风里
[考研] 0856调剂,是学校就去 +8 sllhht 2026-03-19 9/450 2026-03-20 14:25 by 无懈可击111
[考研] 一志愿中国海洋大学,生物学,301分,求调剂 +5 1孙悟空 2026-03-17 6/300 2026-03-19 23:46 by zcl123
[考研] 081700化工学硕调剂 +3 【1】 2026-03-16 3/150 2026-03-19 23:40 by edmund7
[考研] 085600材料与化工调剂 324分 +10 llllkkkhh 2026-03-18 12/600 2026-03-19 14:33 by llllkkkhh
[考研] 328求调剂,英语六级551,有科研经历 +3 生物工程调剂 2026-03-17 7/350 2026-03-18 20:41 by Wangjingyue
[考研] 311求调剂 +6 26研0 2026-03-15 6/300 2026-03-18 14:43 by haxia
[考研] 304求调剂 +12 小熊joy 2026-03-14 13/650 2026-03-18 12:34 by Linda Hu
[考研] 0854,计算机类招收调剂 +3 胡辣汤放糖 2026-03-15 6/300 2026-03-18 12:09 by 上岸上岸……..
[考研] 278求调剂 +5 烟火先于春 2026-03-17 5/250 2026-03-18 08:43 by 星空星月
[考研] 290求调剂 +3 p asserby. 2026-03-15 4/200 2026-03-17 16:35 by wangkm
[考研] 一志愿南京大学,080500材料科学与工程,调剂 +4 Jy? 2026-03-16 4/200 2026-03-17 11:02 by gaoqiong
[考研] 26考研一志愿中国石油大学(华东)305分求调剂 +3 嘉年新程 2026-03-15 3/150 2026-03-15 13:58 by 哈哈哈哈嘿嘿嘿
[考研] 本科南京大学一志愿川大药学327 +3 麦田耕者 2026-03-14 3/150 2026-03-14 20:04 by 外星文明
信息提示
请填处理意见