How to avoid symbolic function when working with results files
Mostrar comentarios más antiguos
The data_temp structure stores all the results for multiple probes for multiple point.
Say we have N probes and M point the structure would be data_temp(N).results(2:1:M)
My goal is to evaluate the integral over one periode of the PF_interface function which is built using multiple results values for all given point.
I could'nt find a way to do it without the symbolic expression but it takes ages to computes which does'nt work when M>1000, thus I'm quite sure it is not the optimal solution. Is there another way around ?
If not I already tried the following:
- going from exact fraction numbers to decimal value (hence de vpa) didn't do anything
- without the m for loop using matrix computation and replacing m by : in my calls, it did not change anything.
The code runs "fast" for x iteration and then slows down by a factor of 100 to 1000x without explanation
Any other way to optimise it ?
I'm using 2013b version for compatibility issues, so no vpaintegral function available for example.
Thanks for your help
syms func_t(t,amp,phase)
func_t(t,amp,phase)=amp*cos(t+phase);
PF_RMS=zeros(1,length(data_temp(1).resultat));
for m=1:length(data_temp(1).resultat)
tic
PF_interface = 0;
for ii=1:3
PF_interface = PF_interface + vpa(func_t(t,data_temp(ii).resultat(1,m),data_temp(ii).resultat(2,m)).*func_t(t,data_temp(ii+3).resultat(1,m),data_temp(ii+3).resultat(2,m)),8);
end
PF_interface=vpa(PF_interface.^2,8);
PF_RMS(m) = sqrt(1/(2*pi)*double(int(PF_interface,t,0,2*pi)));
toc
end
9 comentarios
Dyuman Joshi
el 13 de Oct. de 2023
Are you using vpa() on symbolic expressions? Why?
Maxime Eckstein
el 13 de Oct. de 2023
Editada: Maxime Eckstein
el 13 de Oct. de 2023
Maxime Eckstein
el 13 de Oct. de 2023
Dyuman Joshi
el 13 de Oct. de 2023
Could you attach the data you are working with? Use the paperclip button to attach.
Maxime Eckstein
el 13 de Oct. de 2023
Star Strider
el 13 de Oct. de 2023
The ‘resultat’ field has one non-zero entry, so it a sort of impulse function —
LD = load('data_temp.mat')
data_temp = LD.data_temp
valeur_label = data_temp.valeur_label
base = data_temp.base;
resultat = data_temp.resultat;
resultat = squeeze(resultat)
figure
plot(base, resultat)
grid
xlim([0 100])
.
Maxime Eckstein
el 13 de Oct. de 2023
Star Strider
el 13 de Oct. de 2023
I figured that.
The Fourier transforms of those data are not going to be very informative, regardless.
Respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
