Error using - Matrix dimensions must agree. Error in mmmmmmmtest1m (line 326) a2=aa-a1;
1 view (last 30 days)
Show older comments
Zafar Iqbal
on 5 Dec 2015
Edited: Walter Roberson
on 5 Dec 2015
Error using -
Matrix dimensions must agree.
Error in mmmmmmmtest1m1m (line 326)
a2=aa-a1;
i am surprised why my a2 not calculating my aa value is ok and a1 but the aa and a1 matrices are not equal when i minus them it gave above error ,i spend 10 days on it but this issue is not solving
---------------------------------
Code Hints:-
u(hour)=hour;
Clothesdrye(hour)=power_pattern(hour,1);
a1=find(Clothesdrye);
------------------------------------------------
stereo=[1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1];
Fan=[0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1];
aa=find(stereo);
bb=find(Fan);
-------------------------------------------
Index
a2=aa-a1;
b2=bb-b1;
% len = min([numel(aa) numel(a1)]);-----1
% a1 = aa(1:len) - a1(1:len);-----2
%a1=linspace(0,14,14);%# 14 values spanning the range 0 to 14------3
%a1=[1 8 9 10 11 12 13 14 15 16 17 22 23 24];----4
i have also tried from 1 to 4 but in vain
i am pasting the bit pattern of variables may be helpful for commenters/guiders below.
Error using -
Matrix dimensions must agree.
Error in WDO_SG_Code_PL_test1m (line 326)
a2=aa-a1;
>> u
u =
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
>> power_pattern
power_pattern =
0 0 0 0 0 0 0 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 1 1 0
>> Clothesdrye
Clothesdrye =
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> a1
a1 =
2 3 4
>> aa
aa =
1 8 9 10 11 12 13 14 15 16 17 22 23 24
>> a1
a1 =
2 3 4
>> a2
Undefined function or variable 'a2'.
>> Dish_washe
Dish_washe =
0 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> b2
Undefined function or variable 'b2'.
>> bb
bb =
9 10 11 12 13 14 15 16 17 19 23 24
>> b1
b1 =
2 3 4 5 6 7 8 10
0 Comments
Accepted Answer
Walter Roberson
on 5 Dec 2015
Edited: Walter Roberson
on 5 Dec 2015
Your aa has is a 14 element row vector. Your a1 is a 3 element row vector. What result are you expecting when you subtract them?
Hint: bsxfun()
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!