Search the given index of a column and then replace the entire column with a single value.

1 view (last 30 days)
I have a matrix QI=1x50 which are the index of Data=100x299. Now I need to replace the entire column of a particular index with the index value Mid=1x299.
Say QI=[14 3 24 100] which are indexes of Data=[0.242 0.0002 0.25 1.002 ] so on upto 100X299 Now replace the column with mid=[0.02 00.3 0.256 0.514] upto 1x299
Thanks in Advance

Accepted Answer

David Hill
David Hill on 27 Feb 2020
Not sure if this is what you want.
[~,col]=ind2sub(size(Data),QI);
Data(:,col)=repmat(Mid,1,length(col));

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!