How do I put a condition into a specific column for matlab?
Afficher commentaires plus anciens
Hi all, Would like to check here on what kind of code I could use to create a specific condition on a particular column for matlab. So here is the case, I have a text file(see attached), with four columns of values in it. And here is the code for matlab as given below
A = dlmread('test1.txt')
B = A>1000
So according to this line of code, I have imported the file and placed them in a matrix A. Subsequently I set a condition for matrix B whereby A has to be of a greater value than 1000. Using this, I was able to get returns of '0' and '1's, which is what I wanted. Now, I want to create a set of conditions such that if column 1, 2 and 3 in any of the rows equals to 1, I will be able to display/print an output in that row that says 'Powergrip'. Apart from that condition, should 1,2 equals to 1 in any of the rows there would be a display in that row that says 'precisiongrip'? I do believe this has to do with a series of if else conditions but Im not exactly sure on how to go about writing this conditions. Please pardon my poor coding abilities as I'm really new to this. Thank you!
2 commentaires
Note that your fopen and fclose are superfluous, as the file ID not used by dlmread.
Your question is not clear: "... there would be a display..." and "...I will be able to display/print an output in that row...", but where do you want to "display" this: in the command window, in a GUI, or do you want to write this to a file?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Low-Level File I/O dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!