Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
Pulkit NCU
Pulkit NCU 2020 年 2 月 4 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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
Vinai Datta Thatiparthi 2020 年 2 月 7 日
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