<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>finding location of an element in a matrix</title>
		<link>https://tibasicdev.wikidot.com/forum/t-257840/finding-location-of-an-element-in-a-matrix</link>
		<description>Posts in the discussion thread &quot;finding location of an element in a matrix&quot; - how do you find the location of an element in a matrix</description>
				<copyright></copyright>
		<lastBuildDate>Mon, 16 Nov 2026 22:44:14 +0000</lastBuildDate>
		
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-257840#post-846095</guid>
				<title>Re: finding location of an element in a matrix</title>
				<link>https://tibasicdev.wikidot.com/forum/t-257840/finding-location-of-an-element-in-a-matrix#post-846095</link>
				<description></description>
				<pubDate>Mon, 09 Aug 2010 06:00:31 +0000</pubDate>
				<wikidot:authorName>Weregoose</wikidot:authorName>				<wikidot:authorUserId>7090</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Disclaimer: This is for the language associated with the TI-83+ through TI-84+SE models. I'm unfamiliar with the syntax you're using.</p> <p>Let's say I have a matrix with five rows and three columns&#8230;</p> <div class="code"> <pre><code>[A] [[4 6 5] [3 9 5] [4 1 2] [7 5 3] [8 1 6]]</code></pre></div> <p>&#8230;and I use <a href="https://tibasicdev.wikidot.com/matr-list">Matr►list(</a> to transform the second column into a list:</p> <div class="code"> <pre><code>Matr►list([A],2, L₁ Done L₁ {6 9 1 5 1}</code></pre></div> <p>(Lists are more flexible, and should be the default if you're working with arrangements of numbers that don't require multiple rows.)</p> <p>Suppose I want to find out which element position has a five in it. Performing the test outright&#8230;</p> <div class="code"> <pre><code>L₁=5 {0 0 0 1 0}</code></pre></div> <p>&#8230;returns a list where each element has been compared. The fourth slot returned &quot;true,&quot; so it evidently holds the five.</p> <p>If you were to now multiply this result by a new list where each element identifies with the position that it occupies&#8230;</p> <div class="code"> <pre><code>Ans*{1,2,3,4,5 {0 0 0 4 0}</code></pre></div> <p>&#8230;just the four gets multiplied by the &quot;1&quot; you saw earlier. You can now take the <a href="https://tibasicdev.wikidot.com/max">max(</a> of this result to obtain your answer.</p> <p>A <a href="https://tibasicdev.wikidot.com/seq">seq(</a> command will produce the ordered list shown above, but there is a different approach: assuming that you have a list prepared in <a href="https://tibasicdev.wikidot.com/ans">Ans</a>, you can multiply <a href="https://tibasicdev.wikidot.com/ans">Ans</a> by zero, <a href="https://tibasicdev.wikidot.com/not">not(</a> all of the elements inside it to turn it into a list of ones, and then take the <a href="https://tibasicdev.wikidot.com/cumsum">cumSum(</a> of that to get the numbers in increasing order. For example:</p> <div class="code"> <pre><code>L₁ {6 9 1 5 1} cumSum(not(0Ans {1 2 3 4 5}</code></pre></div> <p>Proceed to multiply that by the binary list generated from a comparison, and then pull out the position number using <a href="https://tibasicdev.wikidot.com/max">max(</a>.</p> <div class="code"> <pre><code>max((L₁=5)cumSum (not(0L₁ 4</code></pre></div> <p>Addendum: You can use a <a href="https://tibasicdev.wikidot.com/for">For(</a> loop to test each column of a multicolumnar matrix.</p> <hr /> <p>Layperson's technique (for the simple-minded):</p> <div class="werecode"> <p>0→A<br /> 0→B<br /> dim([A]→L<span style="font-size:smaller;">1</span><br /> For(R,1,L<span style="font-size:smaller;">1</span>(1<br /> For(C,1,L<span style="font-size:smaller;">1</span>(2<br /> If 5=[A](R,C<br /> Then<br /> R→A<br /> C→B<br /> End<br /> End<br /> End<br /> Disp &quot;ROW:&quot;,A,&quot;COLUMN:&quot;,B</p> </div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-257840#post-846019</guid>
				<title>finding location of an element in a matrix</title>
				<link>https://tibasicdev.wikidot.com/forum/t-257840/finding-location-of-an-element-in-a-matrix#post-846019</link>
				<description></description>
				<pubDate>Mon, 09 Aug 2010 03:04:46 +0000</pubDate>
				<wikidot:authorName>homercimpson</wikidot:authorName>				<wikidot:authorUserId>536062</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Say i have a column matrix [a,b,c&#8230;z] and i store it in the variable AA. how would i go about finding the location of an element like b?<br /> The question is the reverse of AA[2]=b. I'm asking how to do something like AA[b]=2. Another example would be AA[c]=3. And keep in mind a,b,c&#8230;z aren't the actual elements i'm using. my matrix begins something like [h,he,li,br&#8230;Rn]</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>