| Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
|
|
|
#1 |
|
高级会员
注册日期: 2008-11-07
住址: 湖南长沙
帖子: 233
声望力: 22 ![]() |
说明:你把你的矩阵放在一个.txt文件中,保存在work文件夹下。这样比直接输入还要省事。
a=load('shuju.txt'); [index1 index2]=size(a); % search the range of a max=0; for j=1:1:index1 count=0; flag=1; for i=1:1:index2 if (a(j,i)==1)&&(flag) count=count+1; flag=0; end if a(j,i)==0 flag=1; end end if max<count max=count; end end % get the value of valuable max(length of matric c) c=zeros(index1,max); for i=1:1:index1 CL=1; k=0; for j=1:1:index2 if (a(i,j)==1) k=k+1; else if k>0 c(i,CL)=k; CL=CL+1; k=0; end end end if k>0 c(i,CL)=k; CL=CL+1; k=0; end end |
|
|
|
![]() |
| 主题工具 | |
| 显示模式 | |
|
|
相似的主题
|
||||
| 主题 | 主题作者 | 版面 | 回复 | 最后发表 |
| simulink中的3/2坐标变换 | hj03063313 | MATLAB论坛 | 2 | 2012-04-09 12:35 |
| [MATLAB基础] k-nearest neighbor | Juicy | MATLAB论坛 | 3 | 2009-04-25 02:02 |
| [求助]批量删除矩阵元素 | walterhj | MATLAB论坛 | 2 | 2009-03-25 16:33 |
| 请教constr函数问题 | nibabashiwo | MATLAB论坛 | 0 | 2009-01-14 14:25 |
| 怎样用窗函数截断IIR滤波器脉冲响应 | wangzhuzhen | MATLAB论坛 | 0 | 2008-11-14 14:53 |