# How to multiply 2 columns by a scalar number in MATLAB

5 views (last 30 days)

Show older comments

Dear All

Hope you all are keeping good.i need 4 columns [X,Y,Z,Volume]in excel and first of all i want to multiply X and Y columns by 0.09 and (Z column contains just one scalar (0.18) value) then want to multiply all these X,Y,Z coordinates to get Volume. the code i am trying is given below. any help is appreciated.

if true

[x, y] = find(handles.maskedImage ~= 0);

% here x and y are created in excel by code line.to calculate the volume. first multiply 0.09 by both columns to get X and Y.

X=times(0.09,x);

Y=times(0.09,y);

Z = repmat(0.18,[length(x),1]);

[FileName,PathName] = uiputfile('*.xls','Save data to spreadsheet');

Volume=times(X,Y,Z);

Data=[X,Y,Z, Volume];

xlswrite([PathName '/' FileName],Data); end

##### 3 Comments

Image Analyst
on 19 Sep 2013

### Accepted Answer

### More Answers (0)

### See Also

### Products

### Community Treasure Hunt

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

Start Hunting!