Matrix dimension Error while attempting to divide
이전 댓글 표시
Dear all,
The following is my Mat lab code:
clc
f = 0:1:100000;
c = (f.^2)*( (2.687/(10000000000000))+ ((7.858/100)/((f.^2)+1.226)) + ((1.481/10000)/((f.^2)+(1.522*(1000000)))) );
But I am getting the error
Error using /
Matrix dimensions must agree.
Error in npb (line 4)
c = (f.^2)*( (2.687/(10000000000000))+ ((7.858/100)/((f.^2)+1.226)) + ((1.481/10000)/((f.^2)+(1.522*(1000000)))) );
How can I fix this. Kindly help.
채택된 답변
추가 답변 (1개)
John D'Errico
2016년 2월 21일
0 개 추천
You knew (for some reason) to use .^ when raising to a power. But with vectors or arrays, you also need to use .* and ./ for element-wise multiplication and division respectively.
댓글 수: 2
Pramod Bharadwaj
2016년 2월 21일
Jan
2016년 2월 21일
@Pramod Bharadwaj: Simply try it:
2 \ 3
2 / 3
So you see: / is the standard division.
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
