# How to check the proportionaly of columns of a complex rectagular matrix?

1 Ansicht (letzte 30 Tage)
Kalasagarreddi Kottakota am 22 Feb. 2023
Bearbeitet: John D'Errico am 22 Feb. 2023
I have a complex matrix G of size 45 x 2, where in magitude wise the 2nd column is very small than 1st.
Here in the code columns of G are created as shown in the code. the files g1 and t are attached here.
I am looking for a correct methodology to check if the columns are propotional in a complex rectagular matrix G?
clear all;
close all;
G = [g1 -g1.*t];
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

John D'Errico am 22 Feb. 2023
Bearbeitet: John D'Errico am 22 Feb. 2023
Checking if two vectors (in your case, just columns of a matrix) are proportional is pretty easy, as well as then computing the constant of proportionality. You need to be careful, as you cannot just test the correlation coefficient between the vectors, since it is trivial to have two distinct vectors that are not proportional at all, yet share a perfect correlation. For example given a vector x, the vectot y=1+x has a correlation coefficient of EXACTLY 1, yet they are not proportional.
whos
Name Size Bytes Class Attributes ans 1x30 60 char cmdout 1x33 66 char g1 45x1 720 double complex t 45x1 360 double
t
t = 45×1
1.0e-03 * -0.1735 -0.1824 -0.1939 -0.2054 -0.2143 -0.2183 -0.2166 -0.2094 -0.1986 -0.1867
plot(t) Unfortunately, I think you misunderstand what can be done here, and even what proportional really means. g1 and g1.*t are NOT proportional to each other. You multutiplied g1 by the elements of another, non-constant vector t. Again, t is not constant. t varies dramatically over the elements of t, so that it even changes sign. So g1 is NOT proportional to g1.*t.
For example, consider the vector
x = [1:5]';
y = randn(5,1);
[x,y,x.*y]
ans = 5×3
1.0000 0.9764 0.9764 2.0000 0.6719 1.3439 3.0000 1.0125 3.0375 4.0000 1.7801 7.1205 5.0000 1.5934 7.9669
Is there any possible reason to decide that x and x.*y are "proportional" to each other? NO.
Given all that, what can you do? You might decide to formulate the question, is there some SCALAR CONSTANT value s, such that given only the vectors g1 and g1.*t, without knowing the vector t, where we can approximate the second vector with the product g1*s?
Honestly, IF you knew the vector t, then
s = mean(t);
would arguably be what you would want to do. But you can try to estimate the SCALAR constant s. The best estimate is: given by the backslash operator:
g2 = g1.*t;
s_est = g1\g2
s_est = -8.2677e-05 + 3.7221e-21i
As you can see, since both g1 and g2 are complex valued, a tiny amount of an imaginary part has crept in, but that is just floating point trash.
A minor problem in this is that the larger values (in magnitude) of g1 become the ones that have the largest influence on the resulting estimate of s. So in fact, we will not find s_est as being the same as mean(t).
mean(t)
ans = -5.1546e-05
And then the pertinent question becomes, how close are the two vectors to being truly proportional? this is a valid question. We might compare the norm(g1*s - g2), then scaled by the norm of g1.
format long g
norm(g1*s_est - g2)/norm(g1)
ans =
0.000114243043261004
That would give us some sort of meaure of how well we did. So a small number here is good. Or, perhaps we could formulate it in the form people often use, where R^2 near 1 is a good thing. So:
1 - norm(g1*s_est - g2)/norm(g1)
ans =
0.999885756956739
So you would say the model is aruably a decent one, that s_est is a decent approximation. Finally, you might decide to plot the two vectors.
plot(1:numel(g1),[g1*s_est,g2],'-o')
Warning: Imaginary parts of complex X and/or Y arguments ignored. Perhaps the problem is you need to appreciate what proportionality means in context.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

William Rose am 22 Feb. 2023
The correlation is a measure of the proportionality of two vectors. When the vectors are complex, the correlation is complex. The magnitude of the complex correlation is between 0 and 1 and is a reasonable measure of proportionality.
The code below displays the mean of each column, and it displays the complex correlation and the magnitude of the complex correlation.
G = [g1 -g1.*t];
fprintf('G(:,1): mean=%.3e + i*%.3e\n',real(mean(G(:,1))),imag(mean(G(:,1))))
G(:,1): mean=1.023e-01 + i*9.341e-02
fprintf('G(:,2): mean=%.3e + i*%.3e\n',real(mean(G(:,2))),imag(mean(G(:,2))))
G(:,2): mean=-3.074e-06 + i*2.825e-05
fprintf('Correlation = %.3f + i*%.3f\n',...
real(corr(G(:,1),G(:,2))),imag(corr(G(:,1),G(:,2))))
Correlation = 0.629 + i*-0.531
fprintf('Abs(corr)=%.3f\n',abs(corr(G(:,1),G(:,2))))
Abs(corr)=0.823
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Waveform Generation finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!