Hi,
I'm not really a programmer and I've been working mostly in Matlab for the last few weeks. Now I need to take my work and translate it to Fortran to integrate it with the rest of the program (which is written in Fortran 77).
I'm just wondering if it's possible to assign the length of the array somewhere in the middle of the program rather than making it an arbitrary long length at the very beginning.
The context is for wavelet transformation where the user can select different types of filters, each having a different length.
Two problems come up by defining the arrays as arbitrarily long:
1. When the filter is arbitrary length, it's difficult to pad the signal appropriately, normally you would have to add n-1 0s to the start of the signal, where n is the length of the filter. In matlab I did:
n = length(filter);
m = length(signal);
paddedsignal = zeros(1,m+n-1);
paddedsignal(1,1:n-1) = zeros(1,1:n-1);
paddedsignal(1,n:m+n-1) = signal(1,1:m);
2. After each iteration of going through the signal, I take the low frequency result and run it through the filter again. Thus each time the size of the input array decreases by a factor of 2(from 16 to 8 to 4 to 2). By making the input array a length of 16 each time (and thus having extra zeros most of the time), it messes up with left shifting, right shifting and convolving. In matlab I did something like:
n = length(input);
output = zeros(1,n/2);
I'm currently using a few obscure tricks to get around parts of the problem(passing the iteration counts to define which values within arrays I pull). I'm wondering if there is a way to make this a much more strait forward and easily manipulated program.
Thanks a bunch in advance for any help.
You can probably tell by my lack of technical jargon I've never taken a programming course before.
I'm not really a programmer and I've been working mostly in Matlab for the last few weeks. Now I need to take my work and translate it to Fortran to integrate it with the rest of the program (which is written in Fortran 77).
I'm just wondering if it's possible to assign the length of the array somewhere in the middle of the program rather than making it an arbitrary long length at the very beginning.
The context is for wavelet transformation where the user can select different types of filters, each having a different length.
Two problems come up by defining the arrays as arbitrarily long:
1. When the filter is arbitrary length, it's difficult to pad the signal appropriately, normally you would have to add n-1 0s to the start of the signal, where n is the length of the filter. In matlab I did:
n = length(filter);
m = length(signal);
paddedsignal = zeros(1,m+n-1);
paddedsignal(1,1:n-1) = zeros(1,1:n-1);
paddedsignal(1,n:m+n-1) = signal(1,1:m);
2. After each iteration of going through the signal, I take the low frequency result and run it through the filter again. Thus each time the size of the input array decreases by a factor of 2(from 16 to 8 to 4 to 2). By making the input array a length of 16 each time (and thus having extra zeros most of the time), it messes up with left shifting, right shifting and convolving. In matlab I did something like:
n = length(input);
output = zeros(1,n/2);
I'm currently using a few obscure tricks to get around parts of the problem(passing the iteration counts to define which values within arrays I pull). I'm wondering if there is a way to make this a much more strait forward and easily manipulated program.
Thanks a bunch in advance for any help.
You can probably tell by my lack of technical jargon I've never taken a programming course before.