Borrar filtros
Borrar filtros

How to add certain elements of an array

4 visualizaciones (últimos 30 días)
Alan Keenan
Alan Keenan el 25 de Ag. de 2020
Comentada: Alan Keenan el 25 de Ag. de 2020
I have two 200 x 200 arrays of pixel values.
They are all negative values representing -dB values
All of the signal pixel values are >= -20.
All other pixel values (no signal) have been forced to -60.
I want to add both arrays so that only the signal pixels are added to have a summated signal intensity.
This relates to TFM imaging in Ultrasonics.
  2 comentarios
MaHa
MaHa el 25 de Ag. de 2020
Convert your -60 values into NaNs :
noSignal = find(A == -60);
A(noSignal = NaN);
Then do your addition
Alan Keenan
Alan Keenan el 25 de Ag. de 2020
Thanks for your answer, however, there appears to be a problem with the syntax of A(noSignal = NaN);
I entered
noSignal = find(img_dbLL == -60);
img_dbLL(noSignal = NaN);
When trying to run, I get the following message:
Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use
'=='.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 25 de Ag. de 2020
Editada: Matt J el 25 de Ag. de 2020
I'll call your two arrays A and B.
map=A<-20 | B<-20;
result=A+B;
result(map)=-60;
  3 comentarios
Matt J
Matt J el 25 de Ag. de 2020
You're welcome, but please Accept-click the asnwer if your issue is resolved.
Alan Keenan
Alan Keenan el 25 de Ag. de 2020
Done, cheers.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by