How to divide a vector by a constant?
조회 수: 1 (최근 30일)
이전 댓글 표시
c=3*10^8
speeds=(.1*c:.9*c/8:.9*c)
y=1/sqrt(1-(speeds.^2./c^2))
What is my error?
댓글 수: 0
채택된 답변
Image Analyst
2021년 9월 16일
The denominator with sqrt() is a vector so you need a dot before the slash
y = 1 ./ sqrt(1 - (speeds .^ 2 ./ c ^ 2))
추가 답변 (1개)
Cris LaPierre
2021년 9월 16일
You need to use elementwise division everywhere in your equation for y
c=3*10^8;
speeds=(.1*c:.9*c/8:.9*c);
% v
y=1./sqrt(1-(speeds.^2./c^2))
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!