Can anyone please help me ? I am not able to find the a value y from x

조회 수: 2 (최근 30일)
Devesh Kumar
Devesh Kumar 2022년 6월 22일
댓글: Devesh Kumar 2022년 6월 22일
for i=1:cf_n
if x1(i,1)<Vrd_cf(i) && x1(i,2)>Vrd_cf(i)
index2(i) = find((abs(xa(i,:)-Vrd_cf(i)) < 0.001),1,"last");
Y_point2(i) = ya(index2(i));
AZ_L(i) = Y_point2(i);
elseif x1(i,2)<Vrd_cf(i) && x1(i,3)>Vrd_cf(i)
index2(i) = find((abs(xb(i,:)-Vrd_cf(i)) < 0.001),1,"last");
Y_point2(i,:) = yb(index2(i));
AZ_L(i) = Y_point2(i);
elseif x1(i,3)<Vrd_cf(i) && x1(i,3)>Vrd_cf(i)
index2(i) = find((abs(xc(i,:)-Vrd_cf(i)) < 0.001),1,"last");
Y_point2(i,:) = yc(index(i));
AZ_L(i) = Y_point2(i);
elseif x1(i,4)<Vrd_cf(i) && x1(i,4)>Vrd_cf(i)
index2(i) = find((abs(xd(i,:)-Vrd_cf(i)) < 0.001),1,"last");
Y_point2(i,:) = yd(index(i));
AZ_L(i) = Y_point2(i);
elseif x1(i,1)>Vrd_cf(i)
AZ_L(i) = 0;
else
AZ_L(i) = 0;
end
end
Here In this code , xa,xb, xc are different equations and these equations is a matrix of 3 rows and 1000 columns
let me take "xa" only , I am just taking an example
xa = [ 1 2 3 .....................; 0.1 0.2 0.3 .....................; .001 .002 .003 .........................]
based on these condition and for loops
i have to get AZ_L which will be [A1;A2:A3], i.e., 3*1 matrix
problems which i am facing is ,
a. Index should be 3*1 but i am geeting 1*3 (the absoulute values of index is correct but vector is wrong )
b. and due to this all this i am getting is 1*3 , and it should be in 3*1

채택된 답변

KSSV
KSSV 2022년 6월 22일
Did you initialize AZ_L? If not initialize it as
AZ_L = zeros(3,1) ;
  댓글 수: 3
KSSV
KSSV 2022년 6월 22일
If your ya is 3*1000, why/ how you are indexing it as ya(index) ??? Indexing should be ya(row,index) right?
Devesh Kumar
Devesh Kumar 2022년 6월 22일
Thanks allot @KSSV , U were a great help

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by