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 (최근 30일)
이전 댓글 표시
%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
채택된 답변
KSSV
2020년 3월 19일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!