楼主: 0°华尔兹
3261 8

[问答] matlab:Subscripted assignment dimension mismatch.错误 [推广有奖]

  • 0关注
  • 0粉丝

本科生

34%

还不是VIP/贵宾

-

威望
0
论坛币
4163 个
通用积分
1.0013
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
10191 点
帖子
22
精华
0
在线时间
157 小时
注册时间
2016-9-22
最后登录
2022-10-23

楼主
0°华尔兹 发表于 2017-2-16 11:07:12 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
T=11; % number of time periods
N=26; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[3]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,4:15); % column numbers in the data matrix that correspond to the independent variables
for t=1:T
    t1=(t-1)*N+1;t2=t*N;
    wx(t1:t2,:)=W*x(t1:t2,:);
end
xconstant=ones(N*T,1);
[nobs K]=size(x);
运行过程中出现了
Subscripted assignment dimension mismatch.

Error in ==> Untitled3 at 48
    wx(t1:t2,:)=W*x(t1:t2,:);
请问怎么修改呀

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:assignment dimension mismatch assign MATLAB matlab

沙发
0°华尔兹 发表于 2017-2-16 21:19:44
求大神指点一下吧![cry][cry][cry]

藤椅
lixuewei3 发表于 2017-2-17 08:56:44
W=normw(W1); % function of LeSage    W1是什么?

板凳
lixuewei3 发表于 2017-2-17 09:09:46
已提示你是那一步wx(t1:t2,:)=W*x(t1:t2,:);维度不匹配造成的错误,你可以查看下wx(t1:t2,:),W*x(t1:t2,:)这两个变量

报纸
0°华尔兹 发表于 2017-2-18 09:37:27
您好,我的W矩阵是26*26的,x是286*14的,还是不太明白是哪里出错了

地板
0°华尔兹 发表于 2017-2-18 09:37:53
lixuewei3 发表于 2017-2-17 09:09
已提示你是那一步wx(t1:t2,:)=W*x(t1:t2,:);维度不匹配造成的错误,你可以查看下wx(t1:t2,:),W*x(t1:t2,:) ...
您好,我的W矩阵是26*26的,x是286*14的,还是不太明白是哪里出错了

7
lixuewei3 发表于 2017-2-19 09:30:02
0°华尔兹 发表于 2017-2-18 09:37
您好,我的W矩阵是26*26的,x是286*14的,还是不太明白是哪里出错了
我按照你这个程序的运行是没问题的:T=11; % number of time periods
N=26; % number of regions
% row-normalize W
W=rand(26,26); % function of LeSage
A=rand(286,15);

x=A(:,4:15); % column numbers in the data matrix that correspond to the independent variables
for t=1:T
    t1=(t-1)*N+1;t2=t*N;
    wx(t1:t2,:)=W*x(t1:t2,:);
end
xconstant=ones(N*T,1);
[nobs K]=size(x);

还有问题可能说明你的W和X的维数并不是你说的那样,你再检查下吧

8
0°华尔兹 发表于 2017-2-27 15:20:07
lixuewei3 发表于 2017-2-19 09:30
我按照你这个程序的运行是没问题的:T=11; % number of time periods
N=26; % number of regions
% row ...
谢谢,已经纠正了

9
玄火小王 发表于 2018-6-5 04:22:20
0°华尔兹 发表于 2017-2-27 15:20
谢谢,已经纠正了
冒昧的请问一下楼主,这个问题怎么纠正的呀?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-2 07:00