Applying function to all cells in a matrix using it as a reference

Good day to everyone,
I've run into a problem which is best described using the following example. Given Matrix A which is defined as
% code
A=[.9 .8 .7
.6 .5 .4];
I need to transform all cells within the aforementioned Matrix A according to the following formula (Fisher's Z transformation)
where a is each cell in Matrix A. I want to create a matrix B where this is the result of this computation. The resulting matrix B would be
if true
% code
B=[1.47 1.09 0.86
0.69 0.54 0.42]
end
Here is the calculation which yielded the last data entry in matrix B

 採用された回答

Image Analyst
Image Analyst 2014 年 12 月 5 日

0 投票

Yes, and so what heppened when you typed that exactly into MATLAB like this:
format short g;
A=[.9 .8 .7
.6 .5 .4];
Z = 0.5 * log((1+A) ./ (1-A))
Did you see something that you did not expect? Or you didn't know ln was done by the log() function? Or you didn't know how to use ./ or parentheses? It's only one line of code virtually identical to your formula, so where are you having trouble?

3 件のコメント

Image Analyst
Image Analyst 2014 年 12 月 5 日
P.S. Let's not call "elements" "cells" because "cells" are a certain type of variable that is well described here.
Andrew Lapointe
Andrew Lapointe 2014 年 12 月 5 日
編集済み: Andrew Lapointe 2014 年 12 月 5 日
Thank you for correcting my terminology, I will change the terms in the question. This works can you please explain why you added a period in your formula?
Image Analyst
Image Analyst 2014 年 12 月 5 日
That does an "element-by-element" divide, rather than a matrix divide. Same as with .* and * - you know what a matrix multiply is, right? And that's different than if you must multiply a(1,1) by b(1,1) and a(2,1) by b(2,1). Matrix multiple multiplies a row by a column and then sums. It's very different.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by