Info
此问题已关闭。 请重新打开它进行编辑或回答。
basic code question
2 次查看(过去 30 天)
显示 更早的评论
Hello,
If I had two vectors x1 and x2. How could I make vector x3 with all the elements of x2 except the first 3 elements and last 3 elements are from x1?
Many thanks
John
1 个评论
Oleg Komarov
2012-3-22
Please give a specific title to your questions. Otherwise it's hard to tell wether you're double-posting or not.
回答(3 个)
Thomas
2012-3-22
Is this what you wanted?
x1=1:10
x2=11:20
y=[x2(3:length(x2)) x1(1:length(x1-3))]
5 个评论
Oleg Komarov
2012-3-22
If same size:
x1(4:end-2) = x2(4:end-2);
Otherwise:
[x1(1:3); x2(4:end-2); x1(end-2:end)]
0 个评论
Geoff
2012-3-22
To get all but the last 3, use this:
x1(1:end-3)
You can work out how to get all but the first 3 =)
And you already know how to concatenate vectors.
1 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!