Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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 个评论
Rik
Rik 2020-2-4
  • 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

回答(1 个)

Vinai Datta Thatiparthi
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!

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by