Removing the columns of a matrix
Mostrar comentarios más antiguos
Hi,
I try to write a code that compares strings in a cell array. In this code, after it compares the strings in the cell array "type", it assigns the corresponding element in lat matrix to lat1 matrix. This situation is same in lat2 and long2 matrices. But in if statement, when it TF≠1, then it assigns 0 element in lat1 matrix. How can I remove the 0 elements from lat1,lat2,long1 and long2 matrices?
clear all
[lat,long,station,type]=textread('latandlong.txt','%f%f%s%s');
lat1=[];
long1=[];
lat2=[];
long2=[];
for i=1:24
TF=strcmpi('down',type{i,:})
if TF==1
lat1(i,:)=lat(i,:);
long1(i,:)=long(i,:);
elseif TF==0
lat2(i,:)=lat(i,:);
long2(i,:)=long(i,:);
end
end
1 comentario
Jan
el 19 de Oct. de 2011
About the useless "clear all" see: http://www.mathworks.com/matlabcentral/answers/16484-good-programming-practice#answer_22301
Respuesta aceptada
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!