If use Excel, that's easy- Find and Replace. In matlab, what I did is this:
Matrix=Matrix(Matrix ~=999)
Here's a simpler example:
a=[1 2 3 4 5 6 7 8 9 ];
b=a(a~=4);
->
b=[1 2 3 5 6 7 8 9]
MATLAB applications, tutorials, examples, tricks, resources,...and a little bit of everything I learned ...
``` version: '1' services: man: build: . image: my-alpine:latest ``` Dockerfile: ``` FROM alpine:latest ENV PYTH...
What if we would like to do the same for a 2D matrix where the elements to be deleted are present in another vector?
ReplyDelete?? I don't quite understand your problem.
ReplyDeleteI have a data for series of all longitudes and latitudes and mangetic latitudes on a file but I have to select the data to plot the data for magnetic latitude for 0 and 10 degree for geographic longitude of 20W-40W and latitude 1- 20S. How can I do for it?
ReplyDeleteanyone suggest me with coding.
THanks,
Np
Hello NPC,
ReplyDeleteI don't really get your questions, sorry. So I have to guess what your problem is. Could you use three layers of if/then command?
Or if the data set is not too big, maybe you can manually delete those points that you don't need to plot?
I think Pranav Jindal's question is what if there are more than one column. I also want to know what if i have five columns and each column may have the number (say, -99) I don't want. How to do it if that row contains -99 no matter on which column, I want to exclude that whole row?
ReplyDeleteMany thanks.
Hello Winifred and NPC, I had a new post on this topic. Please check my latest post here:
ReplyDeletehttp://matlabnewbie.blogspot.com/2011/11/remove-any-rows-that-contains-specific.html
I hope this is helpful to you two.
Hi All,
ReplyDeleteI am having a big matrix of dimension 36000x7 and I want to delete every 2nd row of this matrix so that finally I am left with a matrix with 18000x7 dim . I don't know how to go about it. I can do the same by extracting one column at a time but that would be time consuming as there are 7 columns and also I have 336 matrices. If I will get to know how to do it for 1 matrix then I will do it for the other ones also. Please help me.......
I think this code can it. I assumed your original matrix is a.
ReplyDeletefor i=1:18000
b(i,:)=a(2*i-1,:)
end
Good luck!
Thanks for your help.....But some how it is not working.......
ReplyDeletefor i=1:18000
ReplyDeleteb(:,i)=a(:,2*i-1)
end
You can get some latest computer tips, blogging tips and internet tips in the blog TechnTechie.
ReplyDeleteb=a(1:2:end,:)
ReplyDeleteThank you for the example. Here's my problem. I have a dataset of X and Y column for which X value there is a corresponding Y value.
ReplyDeleteI need to exclude the rows of X values that are outliers so Y values get removed as well.
I have identified the values that need to be excluded. Stored as an array in a double form.
Say the values are stored under 'out'.
trial=X(X~='out');
Undefined function 'ne' for input arguments of type 'dataset'.
But I am assuming the corresponding values of Y for those X values won't be removed.
X = X(out, :)
DeleteY = Y(out,:)
should do the trick fore you.
**for you
Delete:)
I hv a 2 D matrix= A=[0 0 1 0 0 2;1 0 1 1 0 0 3]
ReplyDeletenad convert it int B=[0 1 2;1 1 3] removing zeros in adjacent rows