Ersetzern Sie alle Indices die Sie in Teilaufgabe c) ermittelt haben, mit einer einzigen Anweisung durch die Zahl 77, und weisen das Ergebis einer Matrix mit dem Namen C5_77 zu.

1 次查看(过去 30 天)
C =
7 5 -6
6 8 4
7 2 8
Indices=C(find(C>5)) ----Hiermit habe ich versucht alle Werte in C zu finden die größer 5 sind.----
Indices =
7
6
7
8
8
Nun ist die Frage wie ich die Werte mit 77 erstezen kann.
Ich habe es folgendermasen versucht
C(Indices)=77 Wobei er hier für C nicht die Zahlenwerte Überschreibt sonder nur die Werte mit der Postionszahl C =
7 5 77
6 8 77
7 77 8
Bin blutiger Anfänger und würde mich über einen Tipp sehr freuen! Lg Jakob

采纳的回答

Jan
Jan 2017-5-23
编辑:Jan 2017-5-23
Indices = C(find(C>5))
This does not reply the "indices", as the names of the variable implies, but the values of C, which are lager than 5. The question asks for the indices and you do need the indices.
The shown code contains the required commands already, so I will help you although this is a homework question:
C(C > 5) % Without: find()
This replies all values of C, which are larger than 5. You can omit the find() and use this efficient "logical indexing". Now you want to assign the value 77 to these elements:
C(C > 5) = 77
By the way: We use English in this forum and the chances to get an answer grow, if more readers can understand the message. There is a German Matlab forum also on demand.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by