how can i assign different values in an array corresponding to values in another array

1 view (last 30 days)
Hi,
I have an array A which has certain zero and non-zero elements(I do not know the length of the array). Ex A= [1,2,3,0,5,0]
I would like to use if conditions to check for the zero and non zero elements.
Then construct arrays X, Y such that
Ex X[i]=5 where A[i]=0 and X[i]=5*pi*sin(pi/2) where A[i]!=0
Y[i]=6 where A[i]=0 and Y[i]=6*5*pi*sin(pi/2 where A[i]!= 0
what i am trying to do is (in C code):
// traversing through a matrix
for (i=0;i<=end of the matrix;i++)
if (condition(element of A =0)) X[i]=5; Y[i]=6;
else if(condition(element of another array=0)) X[i]=5; Y[i]=6;
else if(another condition)
.........
........
else X[i]=5*A[i]*B[i] Y[i]=6*A[i]*B[i]
I would really appreciate a response
Thank you.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!