How can I construct the array problem?

Help with this matlab problem, i don't know how to assign values to the array?

  • This is the question Check every elements inside the second column of Test Data. If the values are greater than 0.5 assign them to array 'A'. If they are less than -0.5 assign them to array B. Other wise assign them to array 'C'. and this is what i have so far, but its not working and i dont know what to do. S= load('/Users/Stayout/desktop/test.txt'); X= S(:,2); A=[]; B=[]; C=[]; for i=1:length(X); if(X(i)>=.5) X(i)= A; elseif (X(i)<=-.5) X(i)= B; else X(i)=C; end end disp (A) disp (B) disp (C) pleaaassee help!!!

  • Answer:

    Try this in the central part... for i = 1 : length(X); if (X(i) >= .5) A(i) = X(i); elseif (X(i) <= -.5) B(i)= X(i); else C(i) = X(i); end A B C If you need more examples with Matlab, I suggest you visit the site below. It's for beginners... Good luck!

Daniel A at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.