I
I
Ilya2018-02-19 21:12:13
Mathematics
Ilya, 2018-02-19 21:12:13

How to implement a formula in matlab?

There is a formula:
fc0f789723f3b0ff8e7222f915f77b37.png
where It is
66f8973c48e82d49029a56bff6d6b11c.png
necessary to score this formula in matlab, subject to the presence of 15 different data arrays. Those. you need to create 105 pairs. I don't understand how to square the difference between an array and its mean. Matlab refuses to do this.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2018-02-19
@Akazotik

1. there are two arrays: c1, c2
2. mean(c1), mean(c2) - calculation of the average for two arrays
3. c1meanc1 = abs(c1-mean(c1)), c2meanc2 = abs(c2-mean(c2) ) - calculation of the difference between the values ​​of the array and the average
4. sum1 = sum(c1meanc1.*c2meanc2) - calculation of the numerator in the formula: the sum of the product of item 3.
5. sqrt1 = sqrt(sum(c1meanc1.*c1meanc1)), sqrt2 = sqrt( sum(c2meanc2.*c2meanc2)) - calculation of the denominator of the formula: the roots of the sums of the square of the difference between the values ​​of the array and its average
6. f = (sum1)/(sqrt1*sqrt2) - the formula itself It
remains to make this formula fulfilled with the above condition.

X
x67, 2018-03-19
@x67

We are not predictors here, so post the code.
--
You are most likely trying to perform a scalar operation on an array, which is not possible. But you can perform this operation on all elements of the array, for this, put a dot in front of the operator, such operations are called "element wise operations", here is an example of elementary multiplication

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question