new to matlab, I am tring to write a peice of code that accepets two premanitars and displys all numbers that have a digit equal to ‘2’ .
Show older comments
This seems like a fairly simple concept but how can i write this so that only number with digits of 2 are displayed. Reading around i found that %c will look for specific characters but i don't understand how to use it. Any help or direction on this matter is apperecated.
2 Comments
Image Analyst
on 11 Jun 2013
What is a "premanitar"?
Kwen
on 13 Jun 2013
I think they meant parameter.
Answers (1)
Sean de Wolski
on 11 Jun 2013
%example x
x = [17.5;12.3;132;211;3.1419];
%convert to string
xstr = num2str(x);
%any column has a digit 2
idx = any(xstr=='2',2);
%Extract from x
x(idx)
Welcome to MATLAB and Answers!
Categories
Find more on Startup and Shutdown 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!