| | |
matlab loop problem
Thread Solved |
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
Hi
I am woring on a for loop to extract selected datas from matlab workspace.The program has some problem to give you an idea what it all about. I want to read 12 datas which follow some pattern in my case every 10 datas that follow a criteria 20 first and then 2 read the 10 datas that follow and 2 and 20 also,these numbers and the data are infinitely many.
so I wrote a code
now what I want as input for another code is D but what the code reads is like
the first value and after the next iteration the first and the second value and it coninues reading like this. So I would like some idea how to read the 10 data's that follow 20&10 every time and allocate the values to D.
Many Thanks
I am woring on a for loop to extract selected datas from matlab workspace.The program has some problem to give you an idea what it all about. I want to read 12 datas which follow some pattern in my case every 10 datas that follow a criteria 20 first and then 2 read the 10 datas that follow and 2 and 20 also,these numbers and the data are infinitely many.
so I wrote a code
j=1;
i=1;
N=length(B); % B is the one dimensional vector which has the %whole datas
for i=1:1:N
if ((B(i)==20) && (B(i+1)==2))
c(j)=i;
j=j+1;
end
end
M=length(b);
k=1;
s=1;
D=ones(12,1);
for k=1:1:M
l=c(k);
for s=1:1:12
D(s)=B(l);
l = (l+1);
end
endthe first value and after the next iteration the first and the second value and it coninues reading like this. So I would like some idea how to read the 10 data's that follow 20&10 every time and allocate the values to D.
Many Thanks
Last edited by Tekmaven; May 30th, 2009 at 3:13 am. Reason: Code Tags
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
Hi
I am woring on a for loop to extract selected datas from matlab workspace.The program has some problem to give you an idea what it all about. I want to read 12 datas which follow some pattern in my case every 10 datas that follow a criteria 20 first and then 2 read the 10 datas that follow and 2 and 20 also,these numbers and the data are infinitely many.
so I wrote a code
now what I want as input for another code is D but what the code reads is likej=1; i=1; N=length(B); % B is the one dimensional vector which has the %whole datas for i=1:1:N if ((B(i)==20) && (B(i+1)==2)) c(j)=i; j=j+1; end end M=length(b); k=1; s=1; D=ones(12,1); for k=1:1:M l=c(k); for s=1:1:12 D(s)=B(l); l = (l+1); end end
the first value and after the next iteration the first and the second value and it coninues reading like this. So I would like some idea how to read the 10 data's that follow 20&10 every time and allocate the values to D.
Many Thanks
![]() |
Similar Threads
- perl loop problem (from a beginner) (Perl)
- Infinite loop problem need help plz (PHP)
- Strange Excel infinite-loop problem (Windows Software)
- a for loop problem (Java)
- Alright this loop problem is bugging me (Java)
- I think Loop problem (Java)
- problem with MATLAB loop (Legacy and Other Languages)
- matlab help -> variable names (Legacy and Other Languages)
- loop problem (C++)
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: ANSI lisp compiler
- Next Thread: datestr
| Thread Tools | Search this Thread |





