Multiply Each Cell Value in Double by 1000

I have a 10801x1 double saved as variable x1 in my workspace and I want to multiply each cell within that double by 1000 and then save the variable as a .txt file, is there a way to do this?

댓글 수: 1

"I want to multiply each cell within that double"
They are referred as elements not cells, as cells in MATLAB mean something else.

댓글을 달려면 로그인하십시오.

답변 (2개)

Arif Hoq
Arif Hoq 2023년 2월 10일

0 개 추천

your_variable=randi(400,10801,1);
out=your_variable*1000;
writematrix(out,'mytextfile.txt')

댓글 수: 4

Could you elaborate what the randi means and where you got the 400 value from?
Arif Hoq
Arif Hoq 2023년 2월 10일
randi is a function to generate random number integer. Here generated random integer number between 1 to 400.
I dont have your variable x1. so I have generated a random number.
Where does 'mytextile.txt' get saved? is there a way to specific the directory?
"Where does 'mytextile.txt' get saved?"
The file gets saved In the current directory. You can find that by typing the command "pwd" in your command line.
"is there a way to specific the directory?"
Yes, refer here - writematrix filename

댓글을 달려면 로그인하십시오.

Dinesh
Dinesh 2023년 2월 10일

0 개 추천

Hi there!
You can use the following code to accomplish what you want:
x1 = x1 * 1000;
dlmwrite('output.txt', x1, 'delimiter', '\n');
The first line multiplies each cell in the array by 1000.
The second line writes the modified array to a text file "output.txt" where each of the cell value occurs in a new line.

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2023년 2월 10일

댓글:

2023년 2월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by