Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 不同长度行的自动连接_Matlab - Fatal编程技术网

Matlab 不同长度行的自动连接

Matlab 不同长度行的自动连接,matlab,Matlab,我有一个行向量x2,还有另外两个行向量x9和x10。我想从x10(1)到x9(1)和x10(2)到x9(2)的x2中提取元素范围。现在的问题是,这些范围的长度不同,因此我无法连接它们。 以下是我迄今为止所尝试的: clear clc x2=[7901 7905 7908 7912 7916 7920 8041 8044 8048 8052 8057 8088 8269 8273 8277]; x10= [8034,8264]; x9=[8074,8304]; for i=1:2 x4=x2(x

我有一个行向量x2,还有另外两个行向量x9和x10。我想从x10(1)到x9(1)和x10(2)到x9(2)的x2中提取元素范围。现在的问题是,这些范围的长度不同,因此我无法连接它们。 以下是我迄今为止所尝试的:

clear
clc
x2=[7901 7905 7908 7912 7916 7920 8041 8044 8048 8052 8057 8088 8269 8273 8277];
x10= [8034,8264];
x9=[8074,8304];

for i=1:2
x4=x2(x2>=x10(i)&x2<=x9(i))
y(i,:)=[x4]
end

% I want to extract elements from x2 within the range x10(1) to x9(1) and then x10(2) to x9(2) so that my result should be: y= [8041 8044 8048 8052 8057 8269 8273 8277]
清除
clc
x2=[7901790579087912179167920804180448048805280578088826982738277];
x10=[80348264];
x9=[80748304];
对于i=1:2
x4=x2(x2>=x10(i)&x2只需使用

[ x2(x2>=x10(1)&x2<=x9(1)) x2(x2>=x10(2)&x2<=x9(2)) ]

[x2(x2>=x10(1)&x2=x10(2)&x2非常完美。谢谢
y = [];
for ii = 1:2
    x4 = x2(x2>=x10(ii)&x2<=x9(ii));
    y = [y x4];
end