Info

This question is closed. Reopen it to edit or answer.

How to creat variable number of matrixes into a loop and how to delete cells of them

1 view (last 30 days)
Hello i would like you to know that i am totally newbie in matlab since i ve been practising something less than a month for my lessons at university anyway the problem is the one that follows I have a variable number of angles from a single point mesured them several times but i dont know how many times they ve been measured . All i know is the value of the angles and the form of the matrix that they are inside. So i have a matrix like this a (angle) b (angle) c (angle) d (angle) . . . . n (angle) 0 a (angle) b (angle) c (angle) d (angle) . . . . n (angle) 0 0 0 a' (angle) b' (angle) c' (angle) d' (angle) . . . . n' (angle) Every time the angles are remesured on the matrix follows 1 zero also every time the point changes that the measures have been done follows 3 zeros. So my problem is how i can break this matrix in other smaller that will have the angles from measured from the same point What i tried to do was s1=size(A) i=s1(1,1) for k = 1 : i if A(k) == 0 & A(k+1) ==0 & A(k+2) ==0 j2=j2+1 end B(k,j3)=A(k,1) end but this dont help much cause it creats a matrix B with many 0 and divides each package of angles to a different array .

Answers (2)

stamatis
stamatis on 17 Mar 2011
i solved it in a way the code goes like this
h=S+m;
t=1;
for k = 1:h:i
DATA(1:S,t)=MT1(k:k+S-1,t);
t=t+1;
end;

Sean de Wolski
Sean de Wolski on 12 Mar 2011
First read this document:
Your method of using multiple file names is advised against and you should look at using arrays (whether normal or cell) to do the work.
Second, can you please post a s small example and/or break your instructions down to individual lines, please? It's very difficult to follow.
  1 Comment
stamatis
stamatis on 13 Mar 2011
i use the enter command but the post system make them a line. I read your answer but from what i understood this is a post about making variables in a matrix not making variable numbers OF matrix
Now i ll try to repost the problem
You have a matrix (N,1) and the module of the N numbers is based on angle measures. The format of the places of the angles is based on a autoinput txt file which is made by the angle meter i use. The format goes like this : You are on a point (x1,y1) you measure angles for the other points u want (x2,y2)....(xn,yn) and u put them on cells. To make sure that your angles are good you do it again but this time every angle you measure is approximately 50 grad bigger ( + , - the error of the mirror instrument) so now when it put the angles on the matrix separates them with one 0 (example : a,b,c,d,e,....,n 0 a',b',c',d',.....n' ) now after you finish with your first point you have to go to the other points you already did the measures and measure all the other points including the points you were standing and measuring before . So if u have measures for n points until u find the first 0 in fact there are n+1 points including the one you were standing and measuring . The times you repeated the measures are how many single 0 exist +1 and the last part of the format is that when you change the point you are standing on and do the measures and go to the next it get separated by three 0 (like this b,c,d,e,....,n 0 b',c',d',.....n' 0 0 0 a,c,d,e,....n 0 a',c',d',.....n')
(the missing a on first package of measures is because u are standing on it the missing b after the three zeros is for the same reason ) So my problem on this format is to make a script that matlab will do automaticaly a seperation on different matrix or arrays the counts for each point so since I have one array with data for all the measures I want to have N arrays (N=the number of the different points) where each N (N1,N2,N3,....Nn) will have inside the measures u done for the other points (example N = [b,c,d,e,....,n 0 b',c',d',.....n' 0 0 0 a,c,d,e,....n 0 a',c',d',.....n'] ---> script i ask for --->
N1= [b,c,d,e,....,n 0 b',c',d',.....n'] N2=[b,c,d,e,....,n 0 b',c',d',.....n'] )
I hope this time its easier to understand what i mean sorry for the bad posting i am new also in the matlab answer blog thank you for your time :)

Community Treasure Hunt

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

Start Hunting!