Info

This question is closed. Reopen it to edit or answer.

Error Showing in my code... Please correct it It is showing matrix dimension must agree in s2

1 view (last 30 days)
clc;
clear all;
close all;
fileID= fopen('reciever_output');
a= fread(fileID);
lastn=3;
tst = a(1:end-lastn,:);
b= length(tst);
c1=[172];
d1= de2bi(c1);
c2= [90];
d2= de2bi(c2);
d=strcat(d1,d2);
rep=floor(b/15);
s1= repmat(d,rep,1);
s2=s1-tst;
num_ele=numel(s2)
nonzero= nnz(s2)
err_c=nonzero/num_ele
  1 Comment
Rik
Rik on 4 Feb 2020
  • You did not attach the necessary data
  • You aren't opening any figures, so there is no need for close all
  • There is no need for clear all, if you want to remove all variables for debugging, use clear or clearvars instead
  • There are no comments in your code, so we have no idea what it is attempting to do
  • You did not describe the inputs on the line that caused the error

Answers (1)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi on 7 Feb 2020
Hello Pulkit,
According to your description, in the line,
s2=s1-tst;
The error you get is pretty clear - the matrices that you're trying to operate on are not of the same sizes. Retrace your steps back to find out the exact specifics. The matrices s1 and tst should be of the same size to be subtracted from each other. It would have been more useful had you shared the file that you're importing.
Hope this helps!

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!