r/matlab

▲ 4 r/matlab

Help! Question About Convolution Integral Implementation in Simulation

Hello all! Hoping someone can help me out with this. I am working on a physics simulation of a rigid body.

I have two functions, f and g that need to be convolved over time. Here is the difficulty, both functions are unpredictable and therefore I do not know these equations up front and will only know the latest value of each of those functions at each time step in the simulation as it runs. I solved this convolution integral in the time domain as a baseline and compared it to a textbook solution. Obviously, the longer the simulations the more data points the equation has to convolve over. I tried solving it in the frequency domain thinking it would save time by: *ifft(fft(F)fft(G))\*timestep*
When I run a code profiler (doing this in MATLAB), it actually appears that it is taking longer computationally to solve this in the frequency domain versus the time domain if this operation is done at every time step… what am I missing here (yes I even varied the simulation time length to account for different array sizes)? The other thought I had was to figure out how to implement a sliding window so that really old data is excluded…

Any examples I can find online all assume the equations for the two signals to convolve are known up front. What approach did you use? Any help would greatly be appreciated.

reddit.com
u/FloridaMan_2023 — 1 day ago
▲ 2 r/matlab

Simulink and AXI-ST IOs

Hello all !

I'm trying to play with HDL Coder and the DSP HDL Library with simulink. I have a solid FPGA background.

All these blocks expose ports that looks like AXI-ST ones (data, valid, ready). I know the protocol and it's quirks, but this time I need to simulate it within simulink.

How do you input data (from workspace) to the model while matching the specifications ? I need to send a waveform (audio in this case) to the model.

Thanks all !

reddit.com
u/Gerard_Mansoif67 — 6 days ago
▲ 6 r/matlab

Printing a hexadecimal value prefixed with 0x

I have to print in hexadecimal with big letters value variable of type uint8. I am using fprintf(1, '%#X', value), but the 0x prefix is in upper case, while I want it to be lowercase. How do I achieve that?

I know I can write instead fprintf(1, '0x%X', value), but I want to do it by only modifying the formatting operators. And using fprintf(1, '%#x', value) doesn't print value in uppercase.

reddit.com
u/Bofact — 8 days ago
▲ 7 r/matlab

Simulink PV Array: Simulation works with a single PV Array but fails when using multiple series PV Arrays

​

Hi everyone,

I’m trying to simulate a PV system in MATLAB/Simulink under normal operating conditions and partial shading conditions.

In Figure 1, I have a PV system using a single MATLAB predefined PV Array block.

Figure 2 shows the advanced parameters of the PV Array, and Figure 3 shows the solver settings I am using.

With this configuration, the simulation works and gives reasonable results. However, I noticed that I only get good results when I use a relatively large input capacitor. With a smaller capacitor, the results are not satisfactory.

I then tried to modify the model by replacing the single PV Array block with multiple PV Arrays connected in series, as shown in Figure 4. I kept the same PV Array parameters and the same solver settings as in the previous model.

However, when I run the simulation, I get the error shown in Figure 5.

I also tried changing the Advanced PV Array parameters, but this results in a different error, shown in Figure 6.

My questions:

1. Why does the simulation work correctly with a single PV Array but produce an error when I use multiple PV Arrays in series?

2. Is there a specific configuration recommended for simulating multiple series-connected PV Arrays, especially when studying partial shading?

I have attached Figures 1–6 showing the model, PV Array parameters, solver settings, and the resulting errors.

Any suggestions or guidance would be greatly appreciated.

Thanks in advance!

u/TrickyAddendum873 — 9 days ago
▲ 1 r/matlab

underground tunnel simulation in matlab

guys if you are proficient and free enough , i need help making a simulation of underground tunnels in matlab . open to advice and criticism , i am a beginner in matlab , i can plot work with matrices and do small project but i do need someones help in this. please dm for more details about the project.

reddit.com
u/Only_Comfortable1607 — 11 days ago
▲ 1 r/matlab

Writing to the wrong file

I have the following Matlab program:

syms t positive;

Z=laplace(exp(A*t))

ccode(Z,'file','cCodeTest.c')

I want to write the Z function to cCodeTest.c. The problem is that code is written to ccodetest.c, created before.

How to write Z to the cCodeTest.c and not ccodetest.c?

reddit.com
u/Bofact — 12 days ago
▲ 21 r/matlab

Level up your documentation game with ASCII-art banners for your MATLAB comments

u/pinriwarb — 13 days ago
▲ 2 r/matlab+1 crossposts

DATCOM and MATLAB

I was working on a project in MATLAB where I needed to import a DATCOM file but no matter what parameters I put, when I import it into MATLAB, the values stored for the control surface coefficients (like DCDI or clroll) are 99999 (NAN). Has anyone experienced anything similar/ has a solution to this?

The input code is as follows-
CASEID ----- MIKOYAN-GUREVICH MiG-17 -----

DIM FT

$FLTCON NMACH=5.0,MACH(1)=0.1,0.2,0.25,0.3,0.35$

$FLTCON

NALPHA=10.0,ALSCHD(1) =-4.0,-2.0,0.0,2.0, 4.0,6.0,8.0,10.0,12.0,14.0$

$FLTCON

NALT=5.0,

ALT(1)= 4500.0,4750.0,5000.0,5250.0,5500.0,

WT=13395.0,LOOP=1.0$

$SYNTHS XCG=11.17,ZCG=0.0,XW=3.63,ZW=0.42,ALIW=1.0,XH=28.73,

ZH=5.24,ALIH=0.0,XV=18.3,ZV=0.0,ZVF=1.0,VERTUP=.TRUE.$

$OPTINS SREF=243.0, CBARR=2.334, BLREF = 9.63$

$BODY NX=8.0,

X(1)=0.0,0.74,8.35,13.14,19.35,24.41,28.41,30.77,

S(1)=5.19,9.32,16.89,16.89,15.94,11.12,5.85,2.5$

NACA-W-6-66-012

$WGPLNF CHRDTP=7.02,SSPNOP=11.32,SSPNE=4.07,SSPN=15.71,

CHRDBP=8.4,CHRDR=14.0,SAVSI=45.0,SAVSO=45.0,CHSTAT=0.25,

TWISTA=0.0,DHDADI=-3.0,DHDADO=-3.0,TYPE=1.0$

NACA-H-6-66-009

$HTPLNF CHRDTP=1.86,SSPNE=5.42,SSPN=5.43,CHRDR=4.69,SAVSI=45.0,

CHSTAT=0.25,TYPE=1.0$

NACA-V-6-66-009

$VTPLNF CHRDTP=3.76,SSPNE=13.41,SSPN=8.18,CHRDR=12.47,SAVSI=55.0,

CHSTAT=0.25,TYPE=1.0$

$SYMFLP

FTYPE=1.0,

CHRDFI=1.407,

CHRDFO=1.407,

SPANFI=1.4,

SPANFO=5.1,

CB=0.12,

TC=0.14,

NTYPE=1.0,

PHETE = 3.03,

NDELTA=7.0,

DELTA(1)=-20.0,-10.0,-5.0,0.0,7.5,15.0,20.0

SCLD=-0.2,-0.1, -0.05,0.0, 0.06, 0.15,0.2

SCMD=-0.2,-0.1, -0.05,0.0, 0.06, 0.15,0.2$

$ASYFLP

STYPE = 4.0,

CHRDFI=2.23,

CHRDFO= 1.85,

SPANFI=9.42,

SPANFO=14.9,

NDELTA=9.0,

DELTAL=20.,15.,10.,5.,0.,-2.5,-5.,-10.,-15.,

DELTAR=20.,15.,10.,5.,0.,-2.5,-5.,-10.,-15.$

DAMP

BUILD

PLOT

NEXT CASE

reddit.com
u/_Birdboii_ — 12 days ago
▲ 1 r/matlab

Particle tracking for biophysics

Having issues trying to set up a particle tracking software for my biophysics research. I am needing to track these very distinct particulates in a video but matlab just doesn't seem to be my friend. I am currently trying to use the particle tracking tutorial from Georgetown but if anyone could give some advice or has anymore questions please shoot me a message.

reddit.com
u/DreamsAreOverated — 14 days ago