Question
if statement: Having one image as a condition and adjusting another image is condition is met. I'm dividing two images (C=A/B). Now my if the pixelintensity in B <= threshold, then the pixel in C should be changed to zero. This is my code so far: if (B <= threshold) C = 0; end However, this does not seem to work. I also thought of first finding the indices in B which are below the threshold and then set these indices to zero, but I couldn't get that right either. Could someone help me further with this?
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 25, 2026
If we assume that B and C are of the same dimension and that you want all elements of C to be set to zero if their corresponding element in B is less than some threshold, then you could perhaps try.
threshold = 0.5; B = rand(5,5); C = rand(5,5); C(B < threshold) = 0;
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related if statement Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →