find the right condition for my script

조회 수: 1 (최근 30일)
Angela Marino
Angela Marino 2020년 7월 9일
편집: madhan ravi 2020년 7월 9일
Given the variables present in the .mat file, I need to find the values ​​of the rows of the "distance" matrix (also using only the first column of values) in correspondence of which I have
in == 1
and
veloc == 0
This is how i wrote my code but i think i was wrong because i can't get the right result
r=0.007*ones(28,1);
[latc, lonc] = scircle1(lat_ferm(:,1), long_ferm(:,1), r);
for l=1:28
in = inpolygon(lat,lon,latc(:,l),lonc(:,l));
veloc_ferm=veloc(in);
idx=double(in(:,1));
%METTERE CONDIZONE SULLA VELOCITA'PER INIDIVIDUARE OPPORTUNAMENTE IDX
%E LA POSIZIONE DELLE FERMATE
[r c] = find(veloc(:,1)==0);
v = diff(r);
[r1 c3] = find(v > 1);
pos_fermateR2(:,1)=distanza(r(r1(in)));
end
  댓글 수: 2
madhan ravi
madhan ravi 2020년 7월 9일
Could you just illustrate with an example of 2x2 matrix and desired result?
Angela Marino
Angela Marino 2020년 7월 9일
Yes, e.g. if I consider only the first column
in=[0 1 1 0 0 0 0 1 1 1 0]';
veloc=[0.213 0 0 1.32 1.34 1.33 1.20 0 0 0 1.34]';
distanza=[10 11 11 12 13 14 15 16 16 16 17]';
pos_fermateR2=[11 16]';

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

채택된 답변

madhan ravi
madhan ravi 2020년 7월 9일
pos_fermateR2 = unique(distanza((in==1) & (veloc==0)))
  댓글 수: 5
Angela Marino
Angela Marino 2020년 7월 9일
Sorry, I meant the value that corresponds to the first instant equal to zero, but for each sequence of zeros
madhan ravi
madhan ravi 2020년 7월 9일
편집: madhan ravi 2020년 7월 9일
You maybe better off starting a new question.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by