matlab如何读取一维数组中的指定某些条件数据,并赋值给不同矩阵
p=[0,0,105,201,0,0,0,211,101,0,0,0,0,205,150,189,0,0,0,0];假设给定的数为上述所示,其中,0的多少以及大于0的数的...
p=[0,0,105,201,0,0,0,211,101,0,0,0,0,205,150,189,0,0,0,0];
假设给定的数为上述所示,其中,0的多少以及大于0 的数的个数都没有规律,现在是想把连续的大于0的数提取出来放到不同的矩阵中,比如
a1[105,201];
a2[211.101];
a3[205,105,189]; 展开
假设给定的数为上述所示,其中,0的多少以及大于0 的数的个数都没有规律,现在是想把连续的大于0的数提取出来放到不同的矩阵中,比如
a1[105,201];
a2[211.101];
a3[205,105,189]; 展开
2个回答
展开全部
给你个例子:
>> a=rand(10,10);
>> a(3:9,2:8)=10
a =
0.1622 0.4505 0.1067 0.4314 0.8530 0.4173 0.7803 0.2348 0.5470 0.9294
0.7943 0.0838 0.9619 0.9106 0.6221 0.0497 0.3897 0.3532 0.2963 0.7757
0.3112 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.7447 0.4868
0.5285 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.1890 0.4359
0.1656 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.6868 0.4468
0.6020 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.1835 0.3063
0.2630 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.3685 0.5085
0.6541 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.6256 0.5108
0.6892 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.7802 0.8176
0.7482 0.4427 0.8001 0.1450 0.2400 0.1112 0.0598 0.4509 0.0811 0.7948
>> a=rand(10,10);
>> a(3:9,2:8)=10
a =
0.1622 0.4505 0.1067 0.4314 0.8530 0.4173 0.7803 0.2348 0.5470 0.9294
0.7943 0.0838 0.9619 0.9106 0.6221 0.0497 0.3897 0.3532 0.2963 0.7757
0.3112 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.7447 0.4868
0.5285 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.1890 0.4359
0.1656 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.6868 0.4468
0.6020 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.1835 0.3063
0.2630 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.3685 0.5085
0.6541 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.6256 0.5108
0.6892 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 0.7802 0.8176
0.7482 0.4427 0.8001 0.1450 0.2400 0.1112 0.0598 0.4509 0.0811 0.7948
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询