请教Matlab函数num2getlastcellnum的用法

查看: 16934|回复: 11|关注: 0
Matlab mat2cell的问题
<h1 style="color:# 麦片财富积分
新手, 积分 5, 距离下一级还需 45 积分
怎样用mat2cell将一个100*100的矩阵分成10个10*100的矩阵?
& & 根据帮助中 c = mat2cell(x,m,n)应该这样写
& & mat2cell(x,[10 10 10 10 10 10 10 10 10 10],[100])
& &能不能有简便的办法?
假如要分成20个5*100的这样写会很笨的。
论坛优秀回答者
帖子最佳答案
关注者: 3154
m=5*ones(1,20);
c = mat2cell(x,m,100);
math (博士、教授)Email: & &&&QQ:
我在网络上的言论、见解等只代表我个人的观念,与任何研究机构、商业公司等无关。欢迎你通过任何方式与我探讨学术和技术上的问题(学生提问的话,请在论坛上发帖提问)。最新日志:
<h1 style="color:# 麦片财富积分
回复 2# math 的帖子
厉害!怎么就想不到呢?
<h1 style="color:# 麦片财富积分
关注者: 2
很受启发,谢谢。
<h1 style="color:# 麦片财富积分
呵呵,大神就是大神啊,很简单的就搞定了
<h1 style="color:# 麦片财富积分
原来可以这样用!太感谢了
<h1 style="color:# 麦片财富积分
学习了,感谢!
<h1 style="color:# 麦片财富积分
看了那么久的代码,还是很差劲啊:Q,总是那么厉害
<h1 style="color:# 麦片财富积分
math 发表于
m=5*ones(1,20);
c = mat2cell(x,m,100);
请问,math,是不是m=5*ones(20,1)啊,20个5*100应该是按列排列的吧。谢谢。
<h1 style="color:# 麦片财富积分
butterfly1107 发表于
请问,math,是不是m=5*ones(20,1)啊,20个5*100应该是按列排列的吧。谢谢。
我觉得也是& &你说得对
站长推荐 /2
Powered by温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(31023)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'[Matlab]从细胞型转换为矩阵From cell to matrix',
blogAbstract:'比如说你有一个细胞型文件,举个例子:&&& a={\'8\';\'8\';\'8\';\'14\';\'21\';\'25\';\'27\';\'31\'}a = &&& \'8\'&&& \'8\'&&& \'8\'&&& \'14\'&&& \'21\'&&& \'25\'&&& \'27\'&&& \'31\'然后呢,你想把这个细胞型文件转成矩阵,数据类型变成double,最简单的思维方式就是cell2mat,先转成string,然后再str2num就好了。很可惜,在matlab里面,cell2mat是默认要求你的矩阵的大小是统一的,可是这里呢,‘8’的长度是1,‘14’的长度是2,所以转换的时候就会出问题,就会出现错误提示。&&& cell2mat(a)??? Error using ==& cat',
blogTag:'cell2mat,cell,mat,细胞型数组,矩阵',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:9,
publishTime:9,
permalink:'blog/static/',
commentCount:2,
mainCommentCount:2,
recommendCount:13,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}  disp函数直接将内容输出在Matlab命令窗口中,
&& 关键是看disp函数怎么把字符和数字在一起进行显示。
matlab中disp()就是屏幕输出函数,类似于c语言中的printf()函数
%%以下是一个通过给定两点显示直线方程的程序,
%%该程序需要给出两个点的坐标,结果返回为y=kx+b的格式,且求得斜率
function [k,a1,b,type]=straight_line(A,B) % 输入,A,B两点坐标
type='undefined';
'The two points are the same'
if V(1)==0 && V(2)==0
disp('Enter two distinct points next time')
if V(1)==0
type='vertical';
elseif V(2)==0
type='horizontal';
type='oblique';
slope=atan2(V(2),V(1));
s=inv([A(1) 1;B(1) 1])*[A(2) B(2)]';
switch type
case 'vertical'
disp('经过这两个点的直线方程为::');
disp(['x = ',num2str(A(1))]);
case 'horizontal'
disp(' 经过这两个点的直线方程为:: ');
disp(['y =',num2str(A(2))])
case 'oblique'
disp(' 经过这两个点的直线方程为:') ;
disp(['y = ',num2str(a) ,' *x +',num2str(b)]);
disp('斜率为:')
k=num2str(a);%将符号数值化
disp(X)函数只有一个输入,当你有多个字符串作为输入时就会报错。
disp('Alice is ' , num2str(12) , ' years old!' );
就会报错--输入参数过多。
但是将里边的内容用中括号一括就成了一个字符串,
str=['Alice is ' num2str(12) ' years old!'];
disp(str);
上边这句话也就等价于:
disp=(['Alice is ' num2str(12) ' years old!']);
这就是加中括号的原因,而不是因为num2str(),
因为disp(num2str(12));也是正确的,因为里边就只有一个字符串。
阅读(...) 评论()}

我要回帖

更多关于 matlab num2cell 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信