how can i use linspace to generate a row vector with two similar points?

4 次查看(过去 30 天)
i am creating an initial guess vector. As i have a multipoint BVPs, i should use double entries in the vector for the interface point. i used linspace(2,20,1000). but i want it to have two 16. how can i do it?
thank you
  2 个评论
dpb
dpb 2013-7-28
What's a BVP?
Please clarify what you really want...give a small example possibly explaining how you arrived at the result.
davood
davood 2013-7-28
BVP stands for boundary value problem. i am using this page: http://www.mathworks.com/help/matlab/math/boundary-value-problems.html
my question is about the part witch is written:
5.Create an initial guess. For multipoint BVPs, when creating an initial guess using bvpinit, use double entries in xinit for the interface point xc.
thank you

请先登录,再进行评论。

采纳的回答

dpb
dpb 2013-7-28
编辑:dpb 2013-7-28
bp=16; % breakpoint value
sp= 2; % startpoint
ep=20; % endpoint
a0=[linspace(sp,bp,N1) linspace(bp,ep,N2)];
N1, N2 could be Ntot/2 or ratio by the distance between breakpoint and overall range to keep uniform or however is best for the particular problem.
If more breakpoints expand on the above.
  2 个评论
dpb
dpb 2013-7-28
W/ time, you'll dream up a zillion other ways to code the above "plain vanilla" approach.... :)
The point of the earlier question was that there's little hope of providing a really responsive answer (as Azzi's shows) w/o the groundrules laid out clearly.

请先登录,再进行评论。

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-7-28
a=sort([16 linspace(2,20,1000)])
  1 个评论
davood
davood 2013-7-28
编辑:davood 2013-7-28
thank you. but if it was linspace(2,21,1000), which does not contain 16, then what could i do to have two 16?
my regards

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by