How to avoid symbolic function when working with results files
이전 댓글 표시
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
Dyuman Joshi
2023년 10월 13일
Are you using vpa() on symbolic expressions? Why?
Maxime Eckstein
2023년 10월 13일
편집: Maxime Eckstein
2023년 10월 13일
Maxime Eckstein
2023년 10월 13일
Dyuman Joshi
2023년 10월 13일
Could you attach the data you are working with? Use the paperclip button to attach.
Maxime Eckstein
2023년 10월 13일
Star Strider
2023년 10월 13일
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
2023년 10월 13일
Star Strider
2023년 10월 13일
I figured that.
The Fourier transforms of those data are not going to be very informative, regardless.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
