Setting a logical matrix to a number
Ältere Kommentare anzeigen
Sorry if this has been posted before - but I couldn't find anything similar!
I have a matrix 176x80, and I've found the local max values which has given me a logical array of the same size
Now I want to change each true value to a certain number on a scale. I defined for the vector for this, and thought I'd need to use a loop - the loop technically works but not in the way I want;
for k=1:14080
if TF_com(k) >= 0.1
TF_com(k)=wavenumber(k);
else TF_com(k)=0;
end
end
Essentially, I want each true value in TF_com to become a wavenumber. However, when I run the code instead of listing the true values in order of wavenumber i.e.
true = wavenumber(1), false = 0, false = 0, true = wavenumber(2)
the loop makes the false values a wavenumber but still shows them as zero
I've tried to add a loop inside, but most of the time I get the error 'arrays don't match in size'
If it helps I know that there are 806 true values, where each one is a different wavenumber
Thanks!!!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!