From: Emil on 27 Jul 2010 06:51 A beautiful solution, thanks
From: Priyanka Choudhary on 27 Jul 2010 12:36 Walter Roberson <roberson(a)hushmail.com> wrote in message <i2ktsd$ij6$2(a)canopus.cc.umanitoba.ca>... > Priyanka Choudhary wrote: > > Hello, > > I'm using MAT-LAB programming for my project work, and for the same I > > have to read columns of the various sequences simultaneously in a single > > array. For that I used the 'fastaread' function and I got my sequences > > in a matrix as cell array like this > > > > Seq=[4x1 char] > > > > And when I'm reading this using 'for' loop I'm getting values like this, > > > > S=[1x439 char] > > [1x404 char] > > [1x404 char] > > [1x343 char] > > > > But instead I want the columns of the sequences used, as like > > s1=M > > P > > I > > L > > > > As, I want to use only the columns for my further calculations. > > So, Please if anyone can look into my problem. > > > What should happen past 343 when data does not exist for all 4 rows ? > > The following uses blanks where the row data does not exist: > > newS = char(S); > > after which newS(:,K) would be the K'th column Thanks a lot... I did'nt new I was doing such a silly mistake. It worked very easily. After that I had a new problem with another syntax used with 'for' loop, which is for i=1:1:num if i==1 A_initial=[ones(1,num_act) zeros(1,num_act*(num-i))] elseif i>1 & i~=num A_initial=[A_initial;zeros(1,num_act*(i-1)) ones(1,num_act) zeros(1,num_act*(num-i))] elseif i==num A_initial=[zeros(1,num_act*(i-1)) ones(1,num_act)] end end In this loop everything is running fine except the first 'elseif' statement. Need a help...! Thanks...
From: Jan Simon on 27 Jul 2010 18:01 Dear Priyanka, > elseif i>1 & i~=num > In this loop everything is running fine except the first 'elseif' statement. > Need a help...! Then do us the favor and specify the problems with this line. Any error messages? Unexpected results? An MLint warning about using &&? Kind regards, Jan
From: Priyanka Choudhary on 28 Jul 2010 01:13 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i2nkv0$94g$1(a)fred.mathworks.com>... > Dear Priyanka, > > > elseif i>1 & i~=num > > > In this loop everything is running fine except the first 'elseif' statement. > > Need a help...! > > Then do us the favor and specify the problems with this line. Any error messages? Unexpected results? An MLint warning about using &&? > > Kind regards, Jan Hello Jan Thanks for looking into my problem. For that statement first the error generated was "not a proper CAT argument"and "dimensions mismatch" but now the loop is not ending, going for infinite iterations and one more thing is that in the statement A_initial=[A_initial;zeros(1,num_act*(i-1)) ones(1,num_act) zeros(1,num_act*(num-i))] First "A_initial" is shown as an error by having a zigzag underline. And when I'm running the same loop for a smaller value then the A_initial matrix for that 'elseif' statement is giving results of only the last iteration, not the whole loop. Please see, if U can help...! Thanks a lot again...!
From: Jan Simon on 28 Jul 2010 16:08 Dear Priyanka, > For that statement first the error generated was "not a proper CAT argument"and "dimensions mismatch" but now the loop is not ending, going for infinite iterations and one more thing is that in the statement > A_initial=[A_initial;zeros(1,num_act*(i-1)) ones(1,num_act) zeros(1,num_act*(num-i))] The loop is going through infinite, although it is control by "for i = 1:num" ?! No, i is not going to infinite. It stops regularly at num. It is just really slow, because you let the variable A_initial grow in each loop. This *must* be slow. Please search the docs and this newsgroup for the term "preallocation". > First "A_initial" is shown as an error by having a zigzag underline. Even Matlab tries to tell you, that this is slow: please move the mouse to the underlined term and read the tooltip. > And when I'm running the same loop for a smaller value then the A_initial matrix for that 'elseif' statement is giving results of only the last iteration, not the whole loop. Not surprising, because you overwrite A_initial in the last iteration. So at first take a look on how to solve this with y loop: A_initial = zeros(num, num_act * num); % Allocate at once!!! for i = 1:num a = num_act * (i -1) + 1; b = a + num_act - 1; A_initial(i, a:b) = 1; end There is no need check for the first or last iteration at all. Even your original code runs find without it. "zeros(1,num_act*(i-1))" replies an empty matrix for i==1, so there is no need to catch this explicitely. Jan
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: MatLab GUI, image rotate Next: Latex Interpreter character spacing |