Matrix - empty selected cells
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
So I have a matrix with some real and some real and imaginary part. .. for example
M = [ 1.23 1.34-4i 275-5i 4; 1.56 1.67 3-3i 5-6i];
I would like to remove the ones with an imaginary part so when I plot them real(M) the real number of the ones that had an imaginary part does not appear and is empty. I need to remember the positions because row and col represent the height and width in my plot.
Is this possible? How on earth can I do this?
When I wrote plot(real(M)).. all the real numbers is plotted even those that had an imaginary part. I just don't seem to figure this out.
Many thanks for assistance... to this conundrum.
0 Kommentare
Antworten (1)
Paulo Silva
am 10 Dez. 2011
You might encounter problems when removing values from array because the dimensions must be consistent
M = [ 1.23 1.34-4i 275-5i 4; 1.56 1.67 3-3i 5-6i];
MM=M; %don't overwrite your original data
MM(imag(M)~=0)=NaN %replace values with imaginary parts
%apply your code to MM, the NaN values are ignored by the plot function
plot(MM)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!