Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Looping and printing matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
if A=[2;4;6;8;6;7]. B=1
C=A-B,
C will become, [1;3;5;7;5;6], since one of the elements of C is 1 or less than one, Z1=B(current)
again i will increase B=2
now C = [0;2;4;6;4;5] since it is the same element which is zero, i want to ignore B(current).
again i will increase B=3
now C = [-1;1;3;5;3;4]. since one more element is equal or less than 1, Z2=B(current)
like this i want to do continously.
How to achieve this.
Any help will be appreciated.
Thanks.
0 Kommentare
Antworten (1)
Image Analyst
am 1 Nov. 2014
When do you stop? Eventually all elements will be 1 or less so you'll just keep increasing B forever and all elements of C will end up moving towards minus infinity. Do you stop when all elements are 1 or less? If so, why not just do
C = A - max(A(:)) + 1;
and not use a loop at all?
2 Kommentare
Image Analyst
am 1 Nov. 2014
You will never have all the elements be 1 if you are subtracting the same number from each element. Just think about it. You will never ever arrive at C=[1,1,1,1,1] by subtracting the same number from [2;4;6;8;6;7].
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!