Make loop more efficient
3 views (last 30 days)
Show older comments
Commented: Panos Kerezoudis on 23 Jan 2023
Hi! I am new to Matlab and I am currently going through coding exerices to become more skilled at it.
I would appreciate any help with making my code below more efficient:
---I have an nxn matrix A and I want to increase all elements below a specific cutoff (let's say 0.5) by a certain value (let's say 1).
This is what I have so far (which thankfully works, but feels bulky).
if A(i) < 0.5
A(i) = A(i) +1;
Matt J on 23 Jan 2023
Edited: Matt J on 23 Jan 2023
More Answers (0)
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!