0

I want to improve my B(H) curve. I want to have a smooth curve without any break in the middle.

enter image description here

The break in the curve is due to the extrapolation made to reach 10^4 A/m (where the slope will become equal to a certain valuemu0). Is there a better way to extrapolate accurately?

Here is the code I implemented to get the curve :

mu0=4*pi*1e-7; % perméabilité du vide 
nu0=1/mu0; % réluctivité du vide 

H_data_ini = [ 0 0.3979 0.7958 1.1937 1.5916 1.9895 2.3874 2.7853 3.1832 3.9790 4.7748 5.9685 7.9580 9.9475 11.9370 15.9160 19.8950 23.8740 31.8320 39.7900 47.7480 59.6850 79.5800 99.4750 119.3700 159.1600 198.9500 238.7400 318.3200 397.9000 477.4800 636.6400 795.8000]

B_data_ini = [ 0    0.0030    0.0090    0.0170    0.0300    0.0520    0.0800    0.1110    0.1360    0.1910    0.2260    0.2660    0.3100    0.3420    0.3670    0.4030    0.4300    0.4520    0.4860    0.5130    0.5340    0.5610    0.5930 0.6190    0.6390    0.6700    0.6920    0.7100    0.7380    0.7550    0.7700    0.7940    0.8060 ]

Bi=0:0.0001:B_data_ini(end);
Hi = interp1(B_data_ini,H_data_ini,Bi);

Hii=B_data_ini(end)+(500:500:1e4);
Bii = interp1(Hi,Bi,Hii,'spline','extrap'); 

% Phytherm260
M_s = Bii(end) - mu0 * Hii(end); 
H_end=Hii(end)+(500:50:2e4);
B_end=mu0.*H_end+M_s;



%% Courbe B(H) expérimental

% Phytherm260 
H_data=[Hi Hii H_end]; 
B_data=[Bi Bii B_end]; 

figure; 
plot(H_data,B_data,'k','LineWidth',2, 'DisplayName', 'T = 20^°C');

I want to have something smooth. I used interp1 to interpolate from 0 to Hi(end) and to extrapolate from Hi(end) to almost 10^4 H/m with the method "spline". I tried all the methods and nothing gives me a smooth extrapolation.

hakim
  • 139
  • 15
  • 1
    "extrapolate" using `interp1` is, as the documentation says, a fill-value, i.e. constant, as you see. Using `interp1` there's no way you can get anything other than constant-value extrapolation. You should probably look for something like a function fit instead. – Adriaan Nov 25 '22 at 13:32
  • @Adriaan As you suggested, I replaced the extrapolation command with this block of commands `Hii=B_data_ini(end)+(500:500:1e4); f = fit(Hi.',Bi.','smoothingspline'); Bii = f(Hii);` I got the same result after trying all the fit types .. – hakim Nov 25 '22 at 13:50
  • 1
    Because you're, again, extrapolating. Instead, as I suggested, fit a function through your data and *extend that function* – Adriaan Nov 25 '22 at 13:51
  • 3
    You should never extrapolate unless you have a model (i.e. you understand how the function behaves). And even then it’s dangerous to extrapolate. – Cris Luengo Nov 25 '22 at 14:18
  • 2
    @Adriaan I don't think it is always a constant fill value. if `'linear'` is given as the fit method then linear extrapolation is used. e.g. `x=1:10;y=1:10;y2=interp1(x,y,1:20,'linear','extrap');y2(end)` outputs `20`, not `10` which is the last value of the input. Without a [mcve] it's impossible to guess, but I think the last two (or more) values in the OP's input might be equal, which would make the extrapolation flat. From my example, you'd get `10` (the held value) out if you had `x=[1:10,11];y=[1:10,10];` with the same extrapolation – Wolfie Nov 25 '22 at 15:08
  • @Wolfie sorry for not giving the data `B_data_ini` and `H_data_ini` because they are confidential.. but if you wanna test my code you can consider `H_data_ini` as a vector line (`0:800`) and `B_data_ini` a vector line (`0:0.8`) – hakim Nov 25 '22 at 16:26
  • Please [edit] that into your question so that we're all on the same page talking about the same "known" [mcve], then we can reproduce your issue and show you how to resolve it for that example – Wolfie Nov 25 '22 at 16:47
  • @Wolfie I edited that in my question. Now you can compile the code and obtain the plot I showed. – hakim Nov 28 '22 at 11:15

0 Answers0