How do I change the size of xq while using the interp1 function as supervision?
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Calvin Kikken
il 7 Ott 2025 alle 14:40
Risposto: Steven Lord
il 7 Ott 2025 alle 15:21
Changing xq size in the interp1 function:
Background
I'm working with persistent phosphors, in my research I'm trying to find out the correlation between the temperature and the amount of traps being released while heating it. So I have a material (Strontiumalumnate SrAl2O4:Eu,Dy) (doped with Europium and Dysprosium) which I bombard with X-rays for an x amount of time, (afterwards I'm letting the material afterglow so the Dysprosium traps will be mostly emptied and the SNR is higher.) this while I cool/heat it at a set temperature. I do this for an y amount of time.
When this is done I heat the material from the set temperature until 225 degrees Celcius with a known β (heating rate), I've chosen it to be 30 K/min so 0,5 K/sec. I'm using a PBS, with a temperature higher the material will melt (I'm measuring this on a Linkam heating stage, so powder is not that practical). The integration time of the spectrometer is 5 seconds, so every five seconds the spectrometer measures a spectrum from 195 until approxiamately 1000 nm. Now I'm interested in the following, the arbitrary intensity as function of temperature and mostly while I'm heating it from the set temperature until 225.
Script status
So I'm firstly determining the x values for the temperatures. Which worked, now I'm trying to interpolate the temperature steps so that the graph can be from -100 degrees Celcius all the way to 225. Which gives me a better insight on which temperature the most traps will be released. Now the error is that these two have different sizes of values while I'm trying to plot the temperature against the interpolation.
Below I have a part of my script which I'm using for this question.
idx = temperature <= 225;
temperature = temperature(idx);
spectra = spectra(:, idx);
controle = zeros(size(spectra,1), length(xq)); % lege matrix voor resultaat
for k = 1:size(spectra,1)
controle(k,:) = interp1(temperature, spectra(k,:), xq, 'spline');
end
Sorry for the mixed Dutch in the script, I'll translate it for easier reading:
controle=checking
lege= empty
voor=for
resultaat= result
I get the following error:
Error using plot
Vectors must be the same length.
Error in TLmin100 (line 34)
plot(temperature, controle);
I'm unsure how to change the size of xq when using the interp1 function. I've tried calculating the amount of steps needed to have the same amount of steps when calculating it without interpolation. This gave the same error.
The sizes of are the following:
size(temperature)
ans =
1 131
size(controle)
ans =
1024 326
I'm curious how I should fix this. Thanks in advance for reading and thinking with me to solve this!
I've added the csv and the matlab script if interested or needed for tips.
0 Commenti
Risposta accettata
Steven Lord
il 7 Ott 2025 alle 15:21
You're interpolating the spectra data at temperatures in xq. Based on what you showed of size(controle) I assume xq has 326 elements. If so, when you call plot you want to specify xq as the X data, not temperature.
As a simple example demonstrating this, let's say we have some sample data.
x = 1:10;
y = x.^2;
xq = 1:0.5:10;
yinterp = interp1(x, y, xq);
Let's look at the sizes of these four variables:
whos
I can plot xq versus yinterp since they both have 19 elements.
plot(xq, yinterp, 'o-')
If I tried to plot x versus yinterp, they're not compatible sizes and so the plot call will error. I have 10 X coordinates and 19 Y coordinates: at which X locations should the other 9 points be plotted? The error message is different, since MATLAB Answers isn't running in release R2020b, but the error has the same root cause.
figure
plot(x, yinterp, 'o-')
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
