필터 지우기
필터 지우기

matlab code running problem

조회 수: 2 (최근 30일)
aniruddh mali
aniruddh mali 2012년 9월 24일
I am trying to run following code on matlab 7.7.0 but it consumes too much time and No output !
for i=1:length(data);
j=1:length(data);
if y1(i)>1.2
f(j)=y1(i);
end
end
it also can not be run on matlab 6 though the developer said that it works on matlab 6.
  댓글 수: 2
Daniel Shub
Daniel Shub 2012년 9월 24일
Please format your code. Are you sure your code is correct? Are you missing a for loop (over j). Can you tell use about data, y1 and f? What do you expect to see and what do you see. How long is "too much time"
Jan
Jan 2012년 9월 24일
Why do you claim that this piece of code does not run under Matlab 6?

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2012년 9월 24일
편집: Jan 2012년 9월 24일
It is not clear what your code should do. Creating "1:length(data)" in each iteration is a waste of time. In addition you overwrite the elements of f most likely.
Did you forget a "for" before "j=..."?
What do you want to achieve?

Javier
Javier 2012년 9월 24일
Hello Mali
What is the purpose of this code ??? Does the variable j change size in each iteration ? If not, do not define it. I believe that you define "j" to establish the size of f. Something that could work better:
j=size(data,1) % for column vector
If want to find the elements in y1 that are greater than 1.2
[r,c,i]=find(y1>1.2); Now you have the row, column and index value that match the search
Now you have the data, What you want to do with them ???
Hope it helps

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by