please help me identufy this.. i write the program but i dont know what this program do.. this is the command.. and output..
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
this is the command
x= [-2 4 7 -9 3 11 7 5 7 ]
[i j ]= size (x)
count = 0 ;
for a = 1 : j
if x (1,a)==7
count=count+1 ;
end
end
count
and this is the output
x =
-2 4 7 -9 3 11 7 5 7
i =
1
j =
9
count =
3
x =
-2 4 7 -9 3 11 7 5 7
i =
1
j =
9
count =
3
please help me to identify this program.. thanks
2 Kommentare
Swarooph
am 9 Feb. 2012
It is just counting the number of '7's in the first row of the variable 'x'. What would you LIKE it to do?
Sean de Wolski
am 9 Feb. 2012
So you wrote it but you don't know what it does? That is a very odd work flow from an engineering standpoint.
Akzeptierte Antwort
Dr. Seis
am 9 Feb. 2012
You are defining an array that is 1 row x 9 columns with values ranging from -9 to 11. You then calculate the "size" of the array and the number of rows are assigned to "i" and the number of columns are assigned to "j". You then initialize "count" to 0 and then loop through all the elements of your array "x" and every time an element in "x" is equal to 7, you increment "count" by 1.
In the future, go to your Help Navigation (little blue question mark) and search for each function within a piece of code you do not understand.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Entering Commands finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!