フィルターのクリア

Multiply Each Cell Value in Double by 1000

10 ビュー (過去 30 日間)
collegestudent
collegestudent 2023 年 2 月 10 日
コメント済み: Dyuman Joshi 2023 年 2 月 10 日
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 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 2 月 10 日
"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 日
your_variable=randi(400,10801,1);
out=your_variable*1000;
writematrix(out,'mytextfile.txt')
  4 件のコメント
collegestudent
collegestudent 2023 年 2 月 10 日
Where does 'mytextile.txt' get saved? is there a way to specific the directory?
Dyuman Joshi
Dyuman Joshi 2023 年 2 月 10 日
"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 日
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.

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by