The horzcat
error is occurring because the dimensions of the matrices you are trying to concatenate horizontally don't match.
To solve this error without using repmat
, you can use the padarray
function in MATLAB to resize the matrices before concatenating them. Here's how you can modify your code:
main.m89 chars2 lines
In this code, padarray
is used to append additional rows or columns of zeros to the matrices. The [0 2]
parameter in the first padarray
call adds 2 columns of zeros to the second matrix, while the [0 0]
parameter in the second padarray
call doesn't add any additional columns.
This modified code will create a matrix x
where the dimensions of the concatenated matrices match, avoiding the horzcat
error.
gistlibby LogSnag