i am having matrix of i rows by 3 columns ,now i want to multiple only i rows of 1 columns with 5 upto 100th row after the 100th row ,values has to be as it is.
1 view (last 30 days)
Show older comments
Harshil Patel
on 8 Jan 2018
Answered: Manan Mishra
on 11 Jan 2018
i= 3560 A = (i,3)
now want to multiple A(i,1) with some value say 5 but upto say 100 and then remaining values of rows has to be same.
and want to save New A(i,1) (change) with 1 to 100 i.e multiplied with 5 and remaining unchanged values in New A(i,1)
0 Comments
Accepted Answer
Manan Mishra
on 11 Jan 2018
Let's assume that you want to multiply the first 'x' rows of the first column with a scalar 'n' and update the values in 'A'.
You can use the following command to do this:
>> A(1:x,1) = n*A(1:x,1);
If you want to do this for multiple columns (say first y columns) at once, you can do similar operation by indexing into columns also:
>> A(1:x,1:y) = n*A(1:x,1:y)
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical 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!