add constant value to row

4 views (last 30 days)
Gemma
Gemma on 22 Jan 2023
Commented: Rik on 30 Jan 2023
Hi,
I need to add a constant value (600) to all rows of my file = DATA. But, I want to add that DATA to an array.
thanks!
  3 Comments
Gemma
Gemma on 22 Jan 2023
Yes .xslx file thanks
Rik
Rik on 30 Jan 2023
@Gemma What makes your question a duplicate? Does either answer work for you? Why didn't you accept either of them? And if they didn't work, why didn't you comment with an explanation of what was different from what you want?

Sign in to comment.

Answers (2)

Matt J
Matt J on 22 Jan 2023
Edited: Matt J on 22 Jan 2023
A=readmatrix('yourFile.xlsx');
A(:,end+1)=600;

VBBV
VBBV on 22 Jan 2023
Edited: VBBV on 22 Jan 2023
A=readmatrix('DATA.xlsx'); % assuming DATA your filename
A(:,end+1)=600;
writematrix(A,'DATA.xlsx','Delimiter','tab') % write data back to same file

Community Treasure Hunt

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

Start Hunting!