LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need help with convolution sum in Labview

Solved!
Go to solution

I uploaded the wrong version, wait here it is corrected

0 Kudos
Message 11 of 27
(192 Views)

@altenbach can you see this final VI correctly?
It's in 2019 with all the datas

0 Kudos
Message 12 of 27
(189 Views)

Yes, this works and produces output. You say that the result is not as expected. What is the expected result?

 

(Sorry, I need to switch to my desktop later. my laptop screen is not big enough to efficiently look at this)

0 Kudos
Message 13 of 27
(184 Views)

I should be obtaining the same graph I obtain in MatLab (the output of waveform graph 3). The output of matlab is attached. 
You're really kind btw thank you so much for your help! 
I will probably look at your adjustments tomorrow morning (I'm in Italy), so feel free to do it when you have time 🙂

0 Kudos
Message 14 of 27
(181 Views)

I can attach the MatLab code that works and does the convolution correctly. 

 
This is the code that I wrote on Matlab (and gives the correct result) and I wanted to implement on LabView:
for i=1:1:200 (200 is Mtot*2-1, I wrote it as a constant on Matlab for simplicity)
l=200;
for k=1:1:200
if i-k>0
c(i)=c(i)+a(k)*b(i-k);
else
c(i)=c(i)+a(k)*b(l);
l=l-1;
end
end
end
This is my implementation of those lines on labview. The problem must be there, as every other part works perfectly (simulation, algorithm one and all the spectrum) or maybe where I mirrored and expanded the periodic spectrum of V and I.
gaiab03_0-1732904825083.png

 

0 Kudos
Message 15 of 27
(176 Views)

Sorry, I no longer do text based code*. Can you save your Matlab output for the current inputs to a simple text file?

 

*(I did text based code from 1973 to 1996, switched to LabVIEW 4.0 and never looed back since 😄 )

0 Kudos
Message 16 of 27
(173 Views)

The output is the graph attached in the previous message (It's in png format). 

Do you prefer another format for images? I can't turn an image into a txt. 

0 Kudos
Message 17 of 27
(165 Views)
Solution
Accepted by topic author gaiab03

@gaiab03 wrote:

I should be obtaining the same graph I obtain in MatLab. The output of matlab is attached. 🙂


If you need to obtain same output as from given script,

 

 

Spoiler
clear all
a=zeros(200, 1);
a(2,1)=-150i;
a(4,1)=-100i;
a(6,1)=-50i;
a(102,1)=-150i;
a(104,1)=-100i;
a(106,1)=-50i;
a(100,1)=150i;
a(98,1)=100i;
a(96,1)=50i;
a(200,1)=150i;
a(198,1)=100i;
a(196,1)=50i;
b=zeros(200, 1);
b(2,1)=-250i;
b(4,1)=-100i;
b(102,1)=-250i;
b(104,1)=-100i;
b(100,1)=250i;
b(98,1)=100i;
b(200,1)=250i;
b(198,1)=100i;
c=zeros(200, 1);
for i=1:1:200
l=200;
for k=1:1:200
if i-k>0
c(i)=c(i)+a(k)*b(i-k);
else
c(i)=c(i)+a(k)*b(l);
l=l-1;
end
end
end

 
% Plot the histogram of abs(c)
figure(1);
bar(1:200, abs(c)); % Plot the absolute values of c
xlabel('Array Indexes');
ylabel('Amplitude');
title('Histogram of abs(c)');
grid on;

 

 

then it could be like this:

Matlab.png

 

The graphs are the same:

 

Screenshot 2024-11-30 00.25.26.png

 

And values are identical:

Screenshot 2024-11-30 00.32.28.png

Some issues may present, but hopefully the overall idea is clear more or less.

0 Kudos
Message 18 of 27
(153 Views)

Thank you so much!
You're really helped me a lot!
The solution works also on my project

0 Kudos
Message 19 of 27
(142 Views)

@Andrey_Dmitriev wrote:

@gaiab03 wrote:

I should be obtaining the same graph I obtain in MatLab. The output of matlab is attached. 🙂


If you need to obtain same output as from given script,

.


It is just a circular convolution and all you need is code the size of a postage stamp. The following gives the same result!

 

altenbach_0-1732982389424.png

 

I changed the cosmetics of the graph to show both as points. Modify as desired.

 

Of course the lingering question is if this is really what you need. 😄

 

Message 20 of 27
(127 Views)