Azzera filtri
Azzera filtri

Regression function NaN r values

2 visualizzazioni (ultimi 30 giorni)
I have the following code:
A = importdata("Fundicion_gris.txt");
B = importdata("Acero_embuticion.txt");
sigma_mpa_embuticion = B.data(:, 1);
epsilon_l_embuticion = B.data(:, 2);
epsilon_t_embuticion = B.data(:, 3);
sigma_mpa_embuticion_lineal = sigma_mpa_embuticion(20:120)
epsilon_l_embuticion_lineal = epsilon_l_embuticion(20:120)
epsilon_t_embuticion_lineal = epsilon_t_embuticion(20:120)
[r, m, b] = regression(epsilon_l_embuticion_lineal, sigma_mpa_embuticion_lineal)
The problem is that the regression function spits out NaN r values, 0 for b values and multiple b values. What am I doing wrong?

Risposta accettata

dpb
dpb il 28 Ott 2023
A = importdata("Fundicion_gris.txt");
B = importdata("Acero_embuticion.txt");
sigma_mpa_embuticion = B.data(:, 1);
epsilon_l_embuticion = B.data(:, 2);
epsilon_t_embuticion = B.data(:, 3);
sigma_mpa_embuticion_lineal = sigma_mpa_embuticion(20:120);
epsilon_l_embuticion_lineal = epsilon_l_embuticion(20:120);
epsilon_t_embuticion_lineal = epsilon_t_embuticion(20:120);
plot(epsilon_l_embuticion_lineal, sigma_mpa_embuticion_lineal)
all(isfinite(epsilon_l_embuticion_lineal))
ans = logical
1
all(isfinite(sigma_mpa_embuticion_lineal))
ans = logical
1
[r, m, b] = regression(epsilon_l_embuticion_lineal.', sigma_mpa_embuticion_lineal.')
r = 0.9999
m = 1.8655e+05
b = 4.5542
I don't know which of the multitude of regression functions your code called; it's a sorry user interface in that it must use a column vector but isn't smart enough to reorient row vectors on its own.
The solution is to transpose your row vectors...
  2 Commenti
Imanol Fernandez de arroyabe Zabala
And how do you know that it needs a column vector? would I have known that if I had looked in the documentation of the function?
dpb
dpb il 28 Ott 2023
Modificato: dpb il 29 Ott 2023
In all likelihood, yes. But, there were several versions that showed up in the doc list when I tried to include a link to it for you and didn't know which Toolboxes you might have. Let's see what's on this online system...
which -all regression
/MATLAB/toolbox/nnet/nnet/nndatafun/regression.m
Well, it only shows one but that TB wasn't in the link the doc link here links to...let's see if we can find it at the home site; I don't have a TB locally that does contain a regression function...
The only one in the DeepLearning TB is not recommended (suggests fitlm from Statistics TB instead) and the only other one is in the Risk Management TB but that doesn't match up with the above indications of something asscociated with the NN stuff.
I have no idea; type
doc regression
and see what it says. The non-recommended one actually did an example with a row but it is a special case of comparing a trained n-network output to an input and that wouldn't have been the one you called; the online version here acts the same as your question, but I don't know that it is the same or not for sure.
How's that for equivocating??? <VBG>
ADDENDUM:
which -all regression
will show you all functions that have that name on your system--you'll probably find only one; it would be interesting to know which it does resolve to...
OBTW, which release of MATLAB are you using, just out of curiosity? I've kept to R2020b or R2021b on local systems to maintain consistency with installed runtime libraries for an app been building on a system for which don't have admin privileges so it's a real pain when something changes and have to get IT involved to let me update...that's nothing at all related to your issue other than I don't have lastest versions locally to see what might be new/different.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by