please help me to fix error and rectify it to a correct programme

1 次查看(过去 30 天)
gamma=0.02
lambda=[0.01:0.0045:0.1]
beta=0.01
m=lambda/gamma
y2=[0.02:0.049:1]
y1=[0.0:0.001:0.02]
y=[y1 y2]
p=y2./lambda
q=y1./lambda
s=beta./lambda
v1=1-exp(-q)
v2=beta*(y2-gamma)+1-exp(-p)+4*sqrt(beta)*(sqrt(exp(-1./m))-sqrt(exp(-y2./lambda)))
v=[v1 v2]
%a
plot(m,v)
errors are
Error using plot
Vectors must be the same lengths.
Error in mytryplugveloctylmbda (line 15)
plot(m,v)
  2 个评论
Alex Mcaulley
Alex Mcaulley 2019-4-10
编辑:Alex Mcaulley 2019-4-10
This is your problem:
length(m)
ans =
21
>> length(v)
ans =
42
What do you want to plot?
Probably is this:
plot(m,v1,m,v2)
Souvick roy
Souvick roy 2019-4-11
actually velocity law are hare depends on distance from
v1 is valid from y=0 to y=delta as mentioned y1
v2 valid from y=delta to y=1 as mentioned y2
and velocity is comprised of both i.ev1 is valid from y=0 to y=delta and v2 valid from y=delta to y=1
i want to plot v againest m

请先登录,再进行评论。

回答(1 个)

David Wilson
David Wilson 2019-4-10
编辑:David Wilson 2019-4-10
In general, it's better to use column vectors by default. That way you don't make mistakes like above when concatenating.
gamma=0.02
lambda=[0.01:0.0045:0.1]' % make a column vector
beta=0.01
m=lambda/gamma
y2=[0.02:0.049:1]'
y1=[0.0:0.001:0.02]'
y=[y1, y2]
p=y2./lambda
q=y1./lambda
s=beta./lambda
v1=1-exp(-q)
v2=beta*(y2-gamma)+1-exp(-p)+4*sqrt(beta)*(sqrt(exp(-1./m))-sqrt(exp(-y2./lambda)))
v=[v1, v2] % check that this is two columns
%a
plot(m,v)
  1 个评论
Souvick roy
Souvick roy 2019-4-11
actually velocity law are hare depends on distance from
v1 is valid from y=0 to y=delta as mentioned y1
v2 valid from y=delta to y=1 as mentioned y2
and velocity is comprised of both i.ev1 is valid from y=0 to y=delta and v2 valid from y=delta to y=1
i want to plot v againest m

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by