# Matrix double and complex double

5 views (last 30 days)
Gisella Agnesia on 31 May 2023
Edited: VBBV on 31 May 2023
Hello, i'm trying to calculate between
t1 = H*(t);
while the H is [32 128] and t is [4096 1] and i was searching for formula to make the matrix has same size and i found this
[m, n] = size(t);
[m1, n1] = size(H);
if m < m1
t(m1,:) = 0; % extend t with rows of zeros, up to the number of rows of H
elseif m > m1
H(m,:) = 0; % extend H with rows of zeros, up to the number of rows of t
end
if n < n1
t(:,n1) = 0; % extend t with columns of zeros, up to the number of columns of H
elseif n > n1
H(:,n) = 0; % extend H with columns of zeros, up to the number of columns of t
end
after i run it both matrix are [4096 128] but i still counldn't calculate it, any ide where the error come? btw the size of H is [4096 128] complex double while t is [4096 128] double, can it be the reason why i cant calculate the t1 = H*(t);? Thankyou!

VBBV on 31 May 2023
Edited: VBBV on 31 May 2023
If you do a check before the if-elseif-else-end statement, the values of m, m1 and n , n1 are same
That leads to the if-elseif - end conditions not satisfied . Hence both matrices remain same despite using some modifications to the H & t matrixces through if-else statements
H = rand(4096,128)
H = 4096×128
0.8248 0.5065 0.6397 0.3823 0.1631 0.4526 0.4803 0.4205 0.3585 0.6254 0.4043 0.4537 0.1282 0.9759 0.0297 0.6665 0.0417 0.5129 0.7328 0.9560 0.4943 0.1993 0.4789 0.3454 0.4706 0.0767 0.8790 0.4529 0.7632 0.0941 0.1576 0.6938 0.8971 0.7983 0.5882 0.6187 0.7386 0.2304 0.3910 0.6098 0.8880 0.8048 0.1135 0.6837 0.3278 0.3102 0.8966 0.6640 0.4464 0.5113 0.5242 0.8953 0.8924 0.0777 0.0707 0.1434 0.2771 0.7708 0.1998 0.0904 0.5800 0.0866 0.1765 0.6705 0.9721 0.7633 0.9729 0.4986 0.0015 0.6913 0.7225 0.8277 0.7736 0.2019 0.6363 0.5111 0.6742 0.7104 0.8213 0.1471 0.9565 0.8706 0.0752 0.4987 0.0775 0.5431 0.0374 0.4943 0.3472 0.2182 0.1233 0.1376 0.0881 0.2288 0.5766 0.4851 0.0181 0.7447 0.4408 0.9133 0.4574 0.8742 0.8483 0.3982 0.5693 0.1391 0.6231 0.1293 0.6229 0.9140 0.3844 0.8080 0.1576 0.4316 0.3006 0.3442 0.2646 0.3979 0.3434 0.3083 0.3815 0.0531 0.7606 0.9830 0.3879 0.7027 0.8342 0.2251 0.7321 0.4491 0.7670 0.2380 0.3642 0.1636 0.8247 0.3907 0.9321 0.5130 0.4630 0.2598 0.8801 0.4539 0.6339 0.5108 0.1941 0.8811 0.9424 0.5381 0.0466 0.3748 0.8431 0.5882 0.1464 0.5800 0.8306 0.2162 0.9301 0.5548 0.2403 0.9455 0.7651 0.8842 0.3984 0.9336 0.7025 0.6080 0.0305 0.2973 0.0150 0.5109 0.2314 0.7521 0.7132 0.7150 0.7869 0.5891 0.0858 0.3538 0.2681 0.1290 0.3491 0.8796 0.6173 0.7562 0.1877 0.4034 0.5856 0.9566 0.0147 0.8303 0.6404 0.1391 0.5439 0.1342 0.0335 0.2289 0.2009 0.7100 0.5003 0.7024 0.7069 0.9861 0.4288 0.3458 0.4213 0.9506 0.2275 0.2073 0.9020 0.5716 0.2080 0.3168 0.3748 0.6354 0.1923 0.4794 0.9376 0.9882 0.3274 0.5828 0.3461 0.2958 0.4937 0.4089 0.9277 0.3657 0.8045 0.5653 0.8416 0.1716 0.6453 0.6166 0.5696 0.9497 0.1110 0.9541 0.0406 0.0930 0.9203 0.0554 0.2974 0.4547 0.6673 0.9973 0.9025 0.4264 0.6619 0.2213 0.3915 0.4140 0.3750 0.2911 0.4523 0.0750 0.5653 0.4484 0.3046 0.0326 0.6191 0.4623 0.9956 0.9210 0.9104 0.7270 0.9109 0.4319 0.7377 0.4575 0.6023 0.3982 0.8833 0.4382 0.5530 0.0458 0.4893 0.1511 0.6733 0.0918 0.9567 0.6369 0.8969 0.5312 0.2578 0.1244 0.9960 0.5650 0.5115 0.5691 0.4740 0.3523 0.8248 0.4821 0.8068 0.2707 0.4022 0.3359 0.3340 0.9818 0.7915 0.9300
t = rand(4096,128)
t = 4096×128
0.5044 0.9611 0.2975 0.3038 0.0623 0.2981 0.6301 0.3950 0.8452 0.1447 0.1038 0.8898 0.8930 0.6736 0.6702 0.6174 0.9974 0.1603 0.1081 0.8914 0.1384 0.9945 0.8592 0.7990 0.4826 0.4927 0.4781 0.2928 0.7482 0.6110 0.5365 0.8015 0.0463 0.0237 0.2513 0.4294 0.4913 0.8559 0.5564 0.8981 0.1752 0.7923 0.6851 0.2720 0.4878 0.5220 0.9193 0.6606 0.4080 0.5387 0.7395 0.6412 0.1132 0.7753 0.2855 0.5286 0.1114 0.7629 0.6140 0.4565 0.1350 0.9931 0.3651 0.5274 0.0744 0.6302 0.4032 0.8477 0.6975 0.6285 0.3557 0.7889 0.5558 0.6224 0.8393 0.8893 0.7035 0.0323 0.0582 0.9516 0.1824 0.1889 0.1159 0.6053 0.2040 0.7907 0.1064 0.4961 0.3629 0.9532 0.6905 0.8708 0.5989 0.9886 0.6274 0.7803 0.7065 0.1125 0.5084 0.8593 0.9604 0.0942 0.8442 0.4489 0.8710 0.4012 0.3620 0.3883 0.3635 0.9371 0.4754 0.0531 0.7584 0.0559 0.8715 0.9147 0.5778 0.1374 0.2748 0.8517 0.0961 0.5118 0.0339 0.1904 0.7185 0.3411 0.3003 0.5676 0.8001 0.4882 0.7657 0.8240 0.6371 0.2179 0.0548 0.6484 0.4220 0.5160 0.5307 0.2923 0.7245 0.2606 0.0474 0.7910 0.1137 0.2463 0.3725 0.4030 0.4773 0.9110 0.9712 0.6535 0.6871 0.2544 0.1657 0.2501 0.8184 0.4696 0.8812 0.9465 0.0423 0.6835 0.4398 0.5723 0.0424 0.4039 0.7016 0.0419 0.6454 0.1797 0.6775 0.4506 0.1911 0.4679 0.6295 0.2801 0.8935 0.5296 0.4285 0.5015 0.4907 0.4949 0.8734 0.1299 0.2968 0.5777 0.1194 0.3140 0.5918 0.0883 0.8359 0.1748 0.0123 0.1190 0.2866 0.1939 0.0924 0.6230 0.9549 0.3560 0.4149 0.3431 0.6646 0.6669 0.6367 0.5791 0.2446 0.9527 0.5711 0.2890 0.1334 0.0930 0.8603 0.7558 0.2922 0.4466 0.7830 0.0370 0.3003 0.2024 0.4662 0.5244 0.6448 0.3503 0.2164 0.9771 0.5432 0.0289 0.8513 0.4166 0.5802 0.6100 0.6414 0.6977 0.1745 0.3120 0.5146 0.1406 0.5175 0.0482 0.2044 0.5622 0.8482 0.5438 0.9975 0.2122 0.5021 0.3541 0.4492 0.8280 0.6190 0.6724 0.5848 0.3663 0.5051 0.4750 0.8299 0.9033 0.5872 0.4053 0.5480 0.9489 0.0263 0.0902 0.9267 0.4542 0.7589 0.0618 0.6380 0.1917 0.2101 0.4962 0.2135 0.2233 0.8769 0.2543 0.5868 0.1662 0.7234 0.8871 0.9886 0.1424 0.1043 0.1238 0.1065 0.4117 0.0543 0.1769 0.4995 0.0145 0.3482 0.7666 0.3474 0.4398 0.0849 0.7942 0.5256 0.4044 0.8917 0.5709
[m, n] = size(t)
m = 4096
n = 128
[m1, n1] = size(H)
m1 = 4096
n1 = 128
% check with this
isequal(m,m1)
ans = logical
1
% check the size
isequal(n,n1)
ans = logical
1
if m < m1
t(m1,:) = 0; % extend t with rows of zeros, up to the number of rows of H
elseif m > m1
H(m,:) = 0; % extend H with rows of zeros, up to the number of rows of t
end
if n < n1
t(:,n1) = 0; % extend t with columns of zeros, up to the number of columns of H
elseif n > n1
H(:,n) = 0; % extend H with columns of zeros, up to the number of columns of t
end
H, t
H = 4096×128
0.8248 0.5065 0.6397 0.3823 0.1631 0.4526 0.4803 0.4205 0.3585 0.6254 0.4043 0.4537 0.1282 0.9759 0.0297 0.6665 0.0417 0.5129 0.7328 0.9560 0.4943 0.1993 0.4789 0.3454 0.4706 0.0767 0.8790 0.4529 0.7632 0.0941 0.1576 0.6938 0.8971 0.7983 0.5882 0.6187 0.7386 0.2304 0.3910 0.6098 0.8880 0.8048 0.1135 0.6837 0.3278 0.3102 0.8966 0.6640 0.4464 0.5113 0.5242 0.8953 0.8924 0.0777 0.0707 0.1434 0.2771 0.7708 0.1998 0.0904 0.5800 0.0866 0.1765 0.6705 0.9721 0.7633 0.9729 0.4986 0.0015 0.6913 0.7225 0.8277 0.7736 0.2019 0.6363 0.5111 0.6742 0.7104 0.8213 0.1471 0.9565 0.8706 0.0752 0.4987 0.0775 0.5431 0.0374 0.4943 0.3472 0.2182 0.1233 0.1376 0.0881 0.2288 0.5766 0.4851 0.0181 0.7447 0.4408 0.9133 0.4574 0.8742 0.8483 0.3982 0.5693 0.1391 0.6231 0.1293 0.6229 0.9140 0.3844 0.8080 0.1576 0.4316 0.3006 0.3442 0.2646 0.3979 0.3434 0.3083 0.3815 0.0531 0.7606 0.9830 0.3879 0.7027 0.8342 0.2251 0.7321 0.4491 0.7670 0.2380 0.3642 0.1636 0.8247 0.3907 0.9321 0.5130 0.4630 0.2598 0.8801 0.4539 0.6339 0.5108 0.1941 0.8811 0.9424 0.5381 0.0466 0.3748 0.8431 0.5882 0.1464 0.5800 0.8306 0.2162 0.9301 0.5548 0.2403 0.9455 0.7651 0.8842 0.3984 0.9336 0.7025 0.6080 0.0305 0.2973 0.0150 0.5109 0.2314 0.7521 0.7132 0.7150 0.7869 0.5891 0.0858 0.3538 0.2681 0.1290 0.3491 0.8796 0.6173 0.7562 0.1877 0.4034 0.5856 0.9566 0.0147 0.8303 0.6404 0.1391 0.5439 0.1342 0.0335 0.2289 0.2009 0.7100 0.5003 0.7024 0.7069 0.9861 0.4288 0.3458 0.4213 0.9506 0.2275 0.2073 0.9020 0.5716 0.2080 0.3168 0.3748 0.6354 0.1923 0.4794 0.9376 0.9882 0.3274 0.5828 0.3461 0.2958 0.4937 0.4089 0.9277 0.3657 0.8045 0.5653 0.8416 0.1716 0.6453 0.6166 0.5696 0.9497 0.1110 0.9541 0.0406 0.0930 0.9203 0.0554 0.2974 0.4547 0.6673 0.9973 0.9025 0.4264 0.6619 0.2213 0.3915 0.4140 0.3750 0.2911 0.4523 0.0750 0.5653 0.4484 0.3046 0.0326 0.6191 0.4623 0.9956 0.9210 0.9104 0.7270 0.9109 0.4319 0.7377 0.4575 0.6023 0.3982 0.8833 0.4382 0.5530 0.0458 0.4893 0.1511 0.6733 0.0918 0.9567 0.6369 0.8969 0.5312 0.2578 0.1244 0.9960 0.5650 0.5115 0.5691 0.4740 0.3523 0.8248 0.4821 0.8068 0.2707 0.4022 0.3359 0.3340 0.9818 0.7915 0.9300
t = 4096×128
0.5044 0.9611 0.2975 0.3038 0.0623 0.2981 0.6301 0.3950 0.8452 0.1447 0.1038 0.8898 0.8930 0.6736 0.6702 0.6174 0.9974 0.1603 0.1081 0.8914 0.1384 0.9945 0.8592 0.7990 0.4826 0.4927 0.4781 0.2928 0.7482 0.6110 0.5365 0.8015 0.0463 0.0237 0.2513 0.4294 0.4913 0.8559 0.5564 0.8981 0.1752 0.7923 0.6851 0.2720 0.4878 0.5220 0.9193 0.6606 0.4080 0.5387 0.7395 0.6412 0.1132 0.7753 0.2855 0.5286 0.1114 0.7629 0.6140 0.4565 0.1350 0.9931 0.3651 0.5274 0.0744 0.6302 0.4032 0.8477 0.6975 0.6285 0.3557 0.7889 0.5558 0.6224 0.8393 0.8893 0.7035 0.0323 0.0582 0.9516 0.1824 0.1889 0.1159 0.6053 0.2040 0.7907 0.1064 0.4961 0.3629 0.9532 0.6905 0.8708 0.5989 0.9886 0.6274 0.7803 0.7065 0.1125 0.5084 0.8593 0.9604 0.0942 0.8442 0.4489 0.8710 0.4012 0.3620 0.3883 0.3635 0.9371 0.4754 0.0531 0.7584 0.0559 0.8715 0.9147 0.5778 0.1374 0.2748 0.8517 0.0961 0.5118 0.0339 0.1904 0.7185 0.3411 0.3003 0.5676 0.8001 0.4882 0.7657 0.8240 0.6371 0.2179 0.0548 0.6484 0.4220 0.5160 0.5307 0.2923 0.7245 0.2606 0.0474 0.7910 0.1137 0.2463 0.3725 0.4030 0.4773 0.9110 0.9712 0.6535 0.6871 0.2544 0.1657 0.2501 0.8184 0.4696 0.8812 0.9465 0.0423 0.6835 0.4398 0.5723 0.0424 0.4039 0.7016 0.0419 0.6454 0.1797 0.6775 0.4506 0.1911 0.4679 0.6295 0.2801 0.8935 0.5296 0.4285 0.5015 0.4907 0.4949 0.8734 0.1299 0.2968 0.5777 0.1194 0.3140 0.5918 0.0883 0.8359 0.1748 0.0123 0.1190 0.2866 0.1939 0.0924 0.6230 0.9549 0.3560 0.4149 0.3431 0.6646 0.6669 0.6367 0.5791 0.2446 0.9527 0.5711 0.2890 0.1334 0.0930 0.8603 0.7558 0.2922 0.4466 0.7830 0.0370 0.3003 0.2024 0.4662 0.5244 0.6448 0.3503 0.2164 0.9771 0.5432 0.0289 0.8513 0.4166 0.5802 0.6100 0.6414 0.6977 0.1745 0.3120 0.5146 0.1406 0.5175 0.0482 0.2044 0.5622 0.8482 0.5438 0.9975 0.2122 0.5021 0.3541 0.4492 0.8280 0.6190 0.6724 0.5848 0.3663 0.5051 0.4750 0.8299 0.9033 0.5872 0.4053 0.5480 0.9489 0.0263 0.0902 0.9267 0.4542 0.7589 0.0618 0.6380 0.1917 0.2101 0.4962 0.2135 0.2233 0.8769 0.2543 0.5868 0.1662 0.7234 0.8871 0.9886 0.1424 0.1043 0.1238 0.1065 0.4117 0.0543 0.1769 0.4995 0.0145 0.3482 0.7666 0.3474 0.4398 0.0849 0.7942 0.5256 0.4044 0.8917 0.5709
VBBV on 31 May 2023
Edited: VBBV on 31 May 2023
Consider the first block of if-elseif-end statements, the if-condition is not satisfied howeever, the else-if condition is satisfied. So when that happens, it is replacing the old rows of H matrix which is m1 =32 with m = 4096 which comes from size of vector t. So essentially,size of H matrix now has become 4096 x 128 . Matlab dynamically resizes the matrix size by creating additional rows with zeros
% H matrix has 128 columns
H = rand(32,128);
% t vector has 4096 rows
t = rand(4096,1);
[m, n] = size(t)
m = 4096
n = 1
[m1, n1] = size(H)
m1 = 32
n1 = 128
% if condition not satisfied
if m < m1
t(m1,:) = 0; % extend t with rows of zeros, up to the number of rows of H
% else-if condition satisfied
elseif m > m1
% H matrix now has 4096 rows and 128 columns
H(m,:) = 0; % extend H with rows of zeros, up to the number of rows of t
end
Now consider the second block of if-elseif-end statements, the if-condition is NOW satisfied howeever, the else-if condition is NOT satisfied. So when that happens, it is replacing the old columns of t vector which is having n = 1 with n1 = 128 which comes from size of Matrix H. So essentially,size of t vector has become 4096 x 128 Matlab dynamically resizes the matrix size by creating additional columns with zeros in this case
% if - condition is satisfied
if n < n1
t(:,n1) = 0; % extend t with columns of zeros, up to the number of columns of H
elseif n > n1
H(:,n) = 0; % extend H with columns of zeros, up to the number of columns of t
end
t1 = H.*t
t1 = 4096×128
0.0171 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.0333 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.1053 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.6407 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.5334 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.0270 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.0183 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.5230 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.2303 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.4120 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
H, t
H = 4096×128
0.9045 0.1728 0.1172 0.9553 0.2894 0.9549 0.1358 0.5462 0.4315 0.7085 0.4188 0.8250 0.4270 0.5251 0.0274 0.0799 0.3562 0.2785 0.8832 0.2869 0.7781 0.7500 0.2384 0.6672 0.5671 0.1972 0.2179 0.0498 0.3485 0.2675 0.0638 0.5702 0.8988 0.5675 0.8214 0.3617 0.3409 0.2946 0.9148 0.6023 0.1960 0.3016 0.0279 0.3007 0.6786 0.0516 0.3244 0.0972 0.9141 0.8544 0.8581 0.2267 0.6678 0.1609 0.0999 0.2160 0.0329 0.0844 0.5640 0.6421 0.9141 0.3137 0.3757 0.2732 0.4752 0.7858 0.6029 0.4603 0.1918 0.4554 0.2906 0.1604 0.9861 0.0161 0.0836 0.4258 0.8005 0.4657 0.5228 0.5862 0.3664 0.8353 0.7963 0.7478 0.4241 0.4349 0.3623 0.8409 0.7588 0.5640 0.9658 0.2282 0.1613 0.9874 0.8953 0.5134 0.5047 0.8240 0.6530 0.8140 0.1005 0.4131 0.5442 0.1734 0.8635 0.3018 0.2119 0.0863 0.0838 0.1018 0.3224 0.4065 0.8095 0.9553 0.0913 0.4334 0.1852 0.2119 0.5176 0.3742 0.6794 0.5030 0.2924 0.5589 0.8415 0.6774 0.9318 0.5754 0.8377 0.9226 0.2094 0.5541 0.6130 0.4069 0.5752 0.1420 0.1194 0.4478 0.2666 0.6399 0.2393 0.5692 0.4043 0.6849 0.9774 0.7320 0.0613 0.4277 0.4008 0.1845 0.0579 0.6307 0.5297 0.8477 0.0287 0.2906 0.8413 0.4434 0.4420 0.5462 0.4701 0.3670 0.4190 0.0003 0.2560 0.8503 0.6570 0.4391 0.7343 0.8000 0.7892 0.2876 0.7730 0.4269 0.9270 0.8541 0.1836 0.7118 0.2765 0.3696 0.0213 0.7707 0.5098 0.0343 0.6806 0.2198 0.6196 0.2674 0.8401 0.5224 0.9199 0.9530 0.3110 0.3548 0.4674 0.8888 0.9840 0.7619 0.0245 0.8218 0.9321 0.2900 0.1015 0.9016 0.2577 0.1049 0.4439 0.7670 0.2397 0.8445 0.7468 0.8361 0.1929 0.4626 0.1593 0.3680 0.6293 0.7714 0.7478 0.5408 0.9575 0.9678 0.7394 0.1996 0.4119 0.0208 0.3617 0.5853 0.4793 0.0381 0.3790 0.2894 0.6494 0.3376 0.7984 0.5722 0.9693 0.8327 0.7299 0.8807 0.3569 0.6938 0.6998 0.6875 0.8171 0.9531 0.4163 0.2257 0.2743 0.1876 0.8834 0.5942 0.4612 0.6662 0.0540 0.0575 0.8787 0.3952 0.9867 0.8091 0.9207 0.6042 0.2710 0.1420 0.3598 0.6002 0.6304 0.1446 0.0348 0.7666 0.5680 0.0898 0.3252 0.0917 0.4472 0.0172 0.1864 0.5738 0.0485 0.5968 0.9634 0.7312 0.7714 0.4632 0.3473 0.7029 0.2143 0.8527 0.9916 0.3408 0.2683 0.1667 0.1774 0.8201 0.8508 0.7262 0.8405 0.5708 0.9209 0.7454
t = 4096×128
0.0189 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.5226 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.1151 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.6634 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.7852 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.4668 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.8580 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.7003 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.6454 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.7255 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
Hence, thats the reason why both H and t will have same sizes now, after the execution of if-else-if-end statement blocks and not due to presence of any complex values in matrix. I hope this clarifies

Walter Roberson on 31 May 2023
That algorithm would be for element-by-element multiplication. For * (matrix multiplication) you need to mentally transpose the second input -- and you only need to match one of the dimensions
%test data
H = rand(32,128);
t = rand(4096,1);
%the algorithm
[m, n] = size(t);
[m1, n1] = size(H);
if n1 < m
H(:,m) = 0; % extend H with columns of zeros, up to the number of rows of t
elseif n1 > m
t(n1,:) = 0; % extend t with rows of zeros, up to the number of columns of H
end
whos
Name Size Bytes Class Attributes H 32x4096 1048576 double cmdout 1x33 66 char m 1x1 8 double m1 1x1 8 double n 1x1 8 double n1 1x1 8 double t 4096x1 32768 double
t1 = H * t;
size(t1)
ans = 1×2
32 1

### Categories

Find more on Buffers, Switches, and Counters in Help Center and File Exchange

R2020a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!