Make specific array from another array elements
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
The problem:
''Write a m.file which is asking to enter array X (integer numbers),which will make a new array Y .Elements of the array Y are sum from even digits of elements array X. If some element of array X is not inteneger,make a comment about error.
For example X = [81, 19, 102, 22, 12, 21] Y = [8, 0, 2, 4, 2, 2]
2 Kommentare
Jan
am 19 Sep. 2022
This sounds like a homework question. It would not be useful, if the forum solves your homework, so you will not get a solution here. Post, what you have tried so far, and ask a specific question about Matlab. Then you will get assistence for solving the specific problem.
Antworten (1)
Walter Roberson
am 19 Sep. 2022
Y = zeros(size(X));
for IndexBackM7 = 1 : numel(Y)
ValueToWorkWIthBackM7 = X(IndexBackM7);
now calculate for ValueToWorkWIthBackM7
Y(idx) = ResultOfCalculationBackM7
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!