herclau

Mr. Hermes Rozsa Iglesias

1038 Reputation

13 Badges

19 years, 189 days

MaplePrimes Activity


These are answers submitted by herclau

 

I link a Maple document:

Spectral_Analysis_Wh.zip

 

@Markiyan Hirnyk 

I would like to play the applet that is within the zip file in Maple.
Or find the procedure that allows me to perform a given experiment with alpha and beta (type I and II) predefined using the least number of experimental data.

Gracias

 

Robert Israel 

I got Error

 

Matrix(8,8,shape=Circulant[[0,1/2,0$n-3,-1/2]]);

Error, (in Matrix) invalid subscript selector


Matrix(8,8, (i,j) -> piecewise(i-j mod n = 1, -1/2, i-j mod n = n -1, 1/2, 0));

****

Gracias

@Christopher2222 

Two Examples

N := 500
t := Vector(N, i->evalf[4]((2*i-2)*Pi/N), datatype = float[8])
x := Vector(N, i-> cos(10*t[i])+I*sin(4*t[i])+ArrayTools[RandomArray](distribution = normal) , datatype = complex[8])
===============================================================================
 rnd := n-> RandomVector(n, generator = (1/10)*rand(-2 .. 2));
 N := 500;
i := <$0 .. N-1>;
t := evalf(2*i*Pi/N);
y := evalf(`~`[cos](10.0*t)+I*`~`[sin](4.0*t));
y := y+rnd(Count(y));
==============================================================================

These three options work satisfactorily. Pay attention to the spaces.


process[launch](cat("sndrec32.exe ", "/play /close ", currentdir(), "\\mywav.wav"));

                          
ssystem(cat("sndrec32.exe ", "/play /close ", currentdir(), "\\mywav.wav"));


process[launch](cat("sndrec32.exe ", "/play ", `"`, currentdir(), "\\mywav.wav", `"`, " /close"));

 I deposited the application, Sndrec32.exe, in the folder where the files to play. Any suggestions?
 
Gracias

this work good, it open , run and close the wav file.

 

Gracias

This may help, but  I can not get the SYNTAX IN MAPLE

(SNDREC32.exe /PLAY "C:\Path\File.wav" /CLOSE)

Gracias

Shift zero-frequency component to center of spectrum

----------------------------------------------------------------------------------

another way to do it whit Maple

 

 

 

Thanks to the instructions of Markiyan Hirnyk, show you this instruction set to achieve the convolution with the help of the package AudioTools. This approach is very fast and handles large volumes of data.

with(AudioTools);
v1 := Vector([1, 2, 1, 2], datatype = float[8]);
v2 := Vector([1, 3, 1, 2], datatype = float[8]);
s1 := [.8147, .9
s2 := [0.975e-1, .2785, .5469, .9575, .9649, .1576, .9706, .9572, .4854, .8003];
MatLab := `<,>`(0.795e-1, .3153, .7102, 1.3999, 2.0389, 1.7996, 2.2764, 3.1658, 2.1398, 2.1994, 2.2745, 1.1502, 1.0379, .5061);

aud := Create(v1);

  [1, 2, 1, 2]

Convolution(v1, v2)

  [1, 5, 8, 9, 11, 4, 4]

aud := Create(s1):

AudT := convert(Convolution(aud, convert(s2, Vector)), Vector[column]);

 <AudT | MatLab>;

What is the difference between v1 and aud delivered by Create?

 

convolution with AudioTools

Gracias

 

 

 

 

 

How I can use the command AudioTools [Convolution] to run the above example?

Could I think of to use the command ImageTools [Convolution]?

Using package command DiscreteTransforms: FourierTransform and InverseFourierTransform:

 s1 := [1, 2, 1, 2]; s2 := [1, 3, 1, 2];
with(DiscreteTransforms);

Digits := 15;
v1 := Vector(nops(s1)+nops(s2)-1, s1, fill = 0);

v2 := Vector(nops(s1)+nops(s2)-1, s2, fill = 0);

FourierTransform(v1, inplace = true, normalization = none);

FourierTransform(v2, inplace = true, normalization = none);

evalf[8]~(Re(InverseFourierTransform(v1*~ v2, normalization = full)));

[1, 5, 8, 9, 11, 4, 4]

 

s1 := [.8147, .9058, .1270, .9134, .6324]
s2 := [0.975e-1, .2785, .5469, .9575, .9649, .1576, .9706, .9572, .4854, .8003]

v1 := Vector(nops(s1)+nops(s2)-1, s1, fill = 0);

v2 := Vector(nops(s1)+nops(s2)-1, s2, fill = 0);

FourierTransform(v1, inplace = true, normalization = none);

FourierTransform(v2, inplace = true, normalization = none);


M:=evalf[8]~(Re(InverseFourierTransform(v1*~ v2, normalization = full)));


Matlab:=<0.795e-1, .3153, .7102, 1.3999, 2.0389, 1.7996, 2.2764, 3.1658, 2.1398, 2.1994, 2.2745, 1.1502, 1.0379, .5061>:


<M|Matlab>;

convolutionWithFFT

Gracias

 

 

 

 

I ask for comments and critical eye to this implementation, since they are present the 10 Hz
How could validate these results?
What is the uncertainty in these results?

 map(with, [plots, DiscreteTransforms, AudioTools]);
audiofile := cat(currentdir(), "\\airconditioner.wav");

x := Read(audiofile);

 fs := attributes(x)[1];


Preview(x, method = nearest, color = [blue]);


 mono := ToMono(x);

Preview(mono, method = nearest, color = [blue]);

 bCall := Vector(mono);


 n := Statistics:-Count(bCall);

tb := Vector(n, proc (i) options operator, arrow; (i-1)/fs end proc);

plot(tb, bCall, style = line, color = blue, title = "airconditioner", labels = ["Time (seconds)", "Amplitude"], axes = box);

m := Statistics:-Count(bCall);
n := 2^ceil(log[2](m));
y := FourierTransform(bCall, normalization = none, padding = n-m)[2];

f := Vector(n, proc (i) options operator, arrow; (i-1)*fs/n end proc);

 p := y*~conjugate~(y)/n;  #Power of the DFT

 plot(f[1 .. floor((1/2)*n)], abs(p[1 .. floor((1/2)*n)]), view = [0 .. 400, DEFAULT], color = blue, style = line, title = "Component Frequencies of an airconditioner", labels = ["Frequency (Hz)", "power"], axes = box);


 plot(f[1 .. floor((1/2)*n)], abs(p[1 .. floor((1/2)*n)]), view = [0 .. 40, DEFAULT], color = blue, style = line, title = "Component Frequencies of an airconditioner", labels = ["Frequency (Hz)", "power"], axes = box);

Spectral Analysis of a airconditioner

airconditioner.mw

Gracias

I hope this document will be useful .. Solving Demodulation as an Optimization Problem

What makes this set of command lines is so inefficient:
1. By increasing n> 8 increases significantly in runtime and graphics.
2. the graphics do not have the resolution presented by the graphs displayed by Robert Israel.

> n := 2^7;
> M := Matrix(n, n, 1, datatype = float[8]);
> Ii := Vector(n, proc (i) options operator, arrow; i end proc, datatype = float[8]);
> x := Vector(n, proc (i) options operator, arrow; Ii[i]-(1/2)*n end proc);
> y := Vector(n, proc (i) options operator, arrow; (1/2)*n-Ii[i] end proc);
> X, Y := Matrix(n, n, proc (i, j) options operator, arrow; x[j] end proc), Matrix(n, n, proc (i, j) options operator, arrow; y[i] end proc);
> R := 10;
> A := `~`[`@`(evalb, `<=`)](`~`[`+`](`~`[`^`](X, 2), `~`[`^`](Y, 2)), R^2);
> M := `~`[evalhf](`~`[`and`](A, M));
> listdensityplot(M, smooth = true, axes = none);
> D1 := FourierTransform(M, normalization = none);
> D2 := ArrayTools[CircularShift](D1, (1/2)*n, (1/2)*n);
> listdensityplot(abs(D2), smooth = true, axes = none, colorstyle = HUE);
> D3 := `~`[log[2]](D2);
> listdensityplot(abs(D3), smooth = true, axes = none, colorstyle = HUE);

Gracias

HERCLAU

 

Brilliant Roberto:

Great, saving resources and commands.
What follows is the following code: 

D1 = fft2(M);
D2 = fftshift(D1);in Maple->ArrayTools[CircularShift](D1, (1/2)*n) o.k?

imagesc(abs(D2))
axis image
colormap(hot)
title('{\bf Diffraction Pattern}')

But what I was interested in obtaining the final matrix M.

What is the equivalent of maple instruction: "meshgrid (x, y)";

Gracias

It will be possible to develop these plots starting from SVD, for example:

Ask_1.mw

Gracias

1 2 3 4 5 6 7 Last Page 2 of 10