Question
Eg: A = [1 2 5; 3 4 6; 7 8 9]; i want to make it A = [1 0 2 5; 3 0 4 6; 0 0 0 0; 7 0 8 9];
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 22, 2026
A = [1 2 5; 3 4 6; 7 8 9] B = zeros(size(A) + 1) B([1 1 0 1]>0,[1 0 1 1]>0) = A
OR
A = reshape(1:9,3,[])'; B = zeros(size(A)+1); m = 3; n = 2; ii = ones(size(B)); ii(m,n) = 0; B((+all(ii,2))*(+all(ii)) > 0) = A;
or just
B(all(ii,2),all(ii)) = A;
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 AI Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →