set some values to zero in a matrix or vector

9 visualizzazioni (ultimi 30 giorni)
Hongmei Hu
Hongmei Hu il 30 Mag 2011
Hi everyone,
I am doing the svd in Simulink, I got the eigenvalue, now I want to set some eigenvalues smaller than a given value to zero. for example, if the eigenvalue small than 2, i set it to zero and keep the those eigen values large than 2 unchanged, incuding the place in the matix and the value.
PS: my matlab is 2009b, there are no Find block. so I can not use that block to find the zero value also.
Thank you very much!

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 30 Mag 2011
How do you do it in Simulink? It sounds like a Matlab data processing problem, e.g.
a=4*rand(3,3)
a(a<2)=0
If you do it in Simulink, what I can think of is that you demux your matrix to individual value, and then use a switch block to compare these individual value, if it is less than 2 then output zero, otherwise, pass it through. At the end, mux them together.
  3 Commenti
Oleg Komarov
Oleg Komarov il 31 Mag 2011
That's what Fangjun's solution does. Did you try his snippet?
Fangjun Jiang
Fangjun Jiang il 31 Mag 2011
@Oleg, I think she is asking if there is an easier way to do it in Simulink. The approach I suggested above in Simulink is a brutal force approach.
@Hongmei Hu, Is there a particular reason that you have to do it in Simulink? To me, SVD is best dealt with using Matlab.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by