MATLAB Answers

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Error in Q38 (line 10) Mat(row,col)=t1

1 view (last 30 days)
Aamir
Aamir on 19 Mar 2020
Answered: KSSV on 19 Mar 2020
%Questions#38
clc
clear
close
N=2
x = [4 9; 8 6]
for row=1:N
for col=1:N
t1=cos(5*3.14*x)
Mat(row,col)=t1
E1=sum(Mat,2)
end
end

  0 Comments

Sign in to comment.

Accepted Answer

KSSV
KSSV on 19 Mar 2020
You have to intilize them either as a cell or matrix. I am intializing as cell. check below:
%Questions#38
clc
clear
close
N=2
x = [4 9; 8 6] ;
Mat = cell(N,N) ;
E1 = cell(N,N) ;
for row=1:N
for col=1:N
t1=cos(5*3.14*x)
Mat{row,col}= t1 ;
E1{row,col}=sum(Mat{row,col},2) ;
end
end

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags