How can I convert a dataset of numbers into a dataset of logarithms of these numbers

38 ビュー (過去 30 日間)
Hi
I have imported an Excel dataset of real-time GDP. Which is a dataset of numbers in a triangular format.
So I want to convert this dataset into logs of these numbers. Is there any fast way??
Many thanks
  3 件のコメント
John D'Errico
John D'Errico 2014 年 7 月 2 日
By using the log function?
Panty
Panty 2014 年 7 月 2 日
The problem is that I am totally newly with matlab. How can I use the log function for the whole dataset?

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2014 年 7 月 2 日
You need to load the dataset into the MATLAB workspace (use xlsread), then simply use the logarithm function of your choice on the entire dataset. Your options are: log (Napierian logarithms), log2 (base 2 logarithms), or log10 (base 10 logarithms). Then save to the file type of your choice. (I suggest a ‘.mat’ file,)
For example:
DataSet = randi(10, 5, 3)
LogDataSet = log10(DataSet)
  13 件のコメント
Panty
Panty 2014 年 7 月 5 日
I see your point.. I will try to use the table function. It may well works for me. I will let you know.
Much appreciated !!
Star Strider
Star Strider 2014 年 7 月 5 日
My pleasure!
The dataset class may be very useful in some situations, but it has serious limitations with respect to doing the sort of operation you want to do. The table class is also a core MATLAB set, and so likely portable amongst a number of different applications. I didn’t try table with your data, but I’ll give it a go if you have problems with it in your application.

サインインしてコメントする。

その他の回答 (1 件)

Panty
Panty 2014 年 7 月 2 日
I have already imported the dataset using 'Import Data' button and I have the dataset in my workspace with 'Value' dataset. And ROUTPUTQvQ19652014 is the name of my dataset.
I used: logReal_GDP= log10(ROUTPUTQvQ19652014)
BUT I GOT : Undefined function 'log10' for input arguments of type 'dataset'.
  1 件のコメント
Panty
Panty 2014 年 7 月 2 日
Is that maybe because I got some negative values or numbers like 2039e+12 in my dataset?

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by