cosd() giving similar value for different angles

6 visualizaciones (últimos 30 días)
Ismita
Ismita el 15 de Mzo. de 2024
Editada: Ismita el 15 de Mzo. de 2024
I have the following code. Though latitude(i) and longitude(i) have different values in degree, Ut and Un are giving the same value. Please help me to find the problem in the following code. Ut and Un should be little different than each other. Thanks a lot
data = load('LatLong.txt');
distance = data(:, 1);
speed_km = data(:, 2);
latitude = data(:, 3);
longitude = data(:, 4);
for i = 1:length(speed_km)
speed_r(i) = speed_km(i) * cosd(latitude(i)) * cosd(longitude(i));
speed_t(i) = speed_km(i) * cosd(latitude(i)) * sind(longitude(i));
speed_n(i) = speed_km(i) * sind(longitude(i));
end
Ur = speed_r;
Ut = speed_t;
Un = speed_n;
figure;
plot(distance, Ur, 'b');
hold on
plot(distance, Ut, 'r');
hold on
plot(distance, Un, 'g'); % need correction for Ut and Un as I am getting only one line (green)
  3 comentarios
Paul
Paul el 15 de Mzo. de 2024
What are Ut and Un?
Ismita
Ismita el 15 de Mzo. de 2024
Editada: Walter Roberson el 15 de Mzo. de 2024
Thanks @Walter Roberson, I have attached the txt file.
Thanks @Paul. Ur, Ut and Un are speed in RTN coordinate. Ur is ok but Ut and Un should be little different. Comparing
speed_t(i) = speed_km(i) * cosd(latitude(i)) * sind(longitude(i));
speed_n(i) = speed_km(i) * sind(longitude(i));
I have found that cosd(latitude) is just 1 for all i as the code is taking instead of the small variation

Iniciar sesión para comentar.

Respuestas (1)

Paul
Paul el 15 de Mzo. de 2024
data = load('LatLong.txt');
speed_km = data(:, 1);
latitude = data(:, 2);
longitude = data(:, 3);
The latitude is quite small, assuming it's actually in degrees.
figure
plot(latitude)
However, the cosd of the latitude isn't exactly one, though it's quite close to one as expected.
figure
plot(cosd(latitude))

Categorías

Más información sobre Just for fun en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by