How to divide a vector by a constant?
2 views (last 30 days)
Show older comments
Lance Shallenberger
on 16 Sep 2021
Commented: Lance Shallenberger
on 16 Sep 2021
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 Comments
Accepted Answer
Image Analyst
on 16 Sep 2021
The denominator with sqrt() is a vector so you need a dot before the slash
y = 1 ./ sqrt(1 - (speeds .^ 2 ./ c ^ 2))
More Answers (1)
Cris LaPierre
on 16 Sep 2021
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))
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!