Replacing values in an array over a certain value

2 visualizaciones (últimos 30 días)
Suniel Mudhar
Suniel Mudhar el 14 de Abr. de 2020
Respondida: Cris LaPierre el 14 de Abr. de 2020
I am currently writing a piece of software that will calculate solar radiation on a vertical plane. I currently have a 1x49 array, containing values for my incident angle, however some of these values are greater than 90, and i wish to minus 180 from them. How do i go about doing that? I have attached my code below.
angleIncidence = acosd((sind(angleDeclin).*sind(lat - tilt))+(cosd(angleDeclin).*cosd(lat-tilt).*cosd(w)));
if angleIncidence > 90
angleIncidence = 180 - angleIncidence;
end
I have also tried:
angleIncidence(angleIncidence > 90) = 180 - angleIncidence

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Abr. de 2020
mask = angleIncidence > 90;
angleIncidence(mask) = 180 - angleIncidence(mask);

Más respuestas (1)

Cris LaPierre
Cris LaPierre el 14 de Abr. de 2020
mod(ang+90,180)-90;

Categorías

Más información sobre Creating and Concatenating Matrices 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