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

1 次查看(过去 30 天)
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?

请先登录,再进行评论。

更多回答(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