Community Profile # Les Beckham

Last seen: 2 dagar ago Active since 2013

Many years developing flight control algorithms and software

Programming Languages:
C++, C, C#, MATLAB, Assembly

#### Statistics

All
• • • • • • • • #### Content Feed

View by

day and month inverted in the time scaling
If you created your "time x array" by reading strings from a text file, for example, you need to specify the 'InputFormat' argum...

5 dagar ago | 1

Optimize live plotting with a large data set
You definitely don't want to call plot repeatedly inside your loop. Here is a suggested approach where I created the plot outsi...

23 dagar ago | 0

Problem 568. Number of 1s in a binary string
The find() function returns the index of all non-zero elements in the input. ASCII characters (like '0' and '1') are all non-ze...

23 dagar ago | 0

| accepted

I have a problem with my code
You have the following important line in your code commented out (the definition of the solve_friction_factor() function). Unco...

23 dagar ago | 0

Matrix to Scalar Problem
t=0:3:60;%seconds Pos0=1;%position <<< Pos0 can't be zero since you divide by Wd*Pos0 when calculating alfa Vel0=0;%velocity ...

25 dagar ago | 1

How to increase the tolerance for comparing time points when synchronizing timetables?
Based on this section of the documentation: Synchronize Timetables to Arbitrary Time Vector N = 9; dt = .3; mkTime = @(t0) ...

30 dagar ago | 0

How to create plot from the data in .txt file ?
This should get you started. Note that the warnings are expected and can be ignored. T = readtable('Spatial Density.txt', 'Emp...

ungefär en månad ago | 4

| accepted

How do you cluster lines in 3D space?
I would suggest something like this since the main difference in your "groups" seems to be the approximate slopes of the three g...

ungefär en månad ago | 0

Converting the outpur of a fit (e.g. sfit) into a string format, then pasting the text to a Text Area in app desginer
Another option (which does essentially the same thing) is this: load census; f = fit(cdate,pop,'poly2'); s = formattedDispl...

ungefär en månad ago | 1

Why is NaN inserted in wrong position?
b = [1 3 0;-2 -1 5]; b(b(:,3)==5,3) = NaN % add ,3 to select only the third column for assignment

ungefär 2 månader ago | 1

How I get the frequencies in Hz of a specific signal?
I think this is close to what you are looking for. % % This code will generate a saltatory stimulus of 10 Hz up to 800 Hrz (the...

ungefär 2 månader ago | 1

How to specify relative code paths in S-function builder

ungefär 2 månader ago | 0

How to calculate the average of a cell array?
T = {[10, 1, 30], [15, 2, 10], [20, 3, 20]} A = vertcat(T{:}) % make an array from the elements of the cell array by stacking t...

ungefär 2 månader ago | 1

errore too many output
You are trying to do this [norm_sp,f_vector]=fft(acc_z,fs(n)); If you look at the documentation for fft you will see that ther...

ungefär 2 månader ago | 0

Read in a general binary file (for example, but not exclusively a jpeg file), make a modification and write a new file out verbatim--no altered bytes.
fileread reads the file as text. You need to open the file and read it as binary bytes (uint8) and then process it that way. R...

| accepted

Having issues with plotting a single level contour line on a matrix that has edges
From your simple example, it can be seen that there actually are two places where the interpolated surface passes through the le...

How to add rows containing zeros to a matrix
Here is another way. A = rand(2,6) A(4,6) = 0

Plotcube function not working
There is a plotcube function on the file exchange: https://www.mathworks.com/matlabcentral/fileexchange/15161-plotcube?s_tid=sr...

Keep the latest desired value before changing to undesired value
There might be a way to do this using just basic Simulink blocks, but I don't have Simulink right now to test with. So, I'm goi...

Iterative Process to find a variable in which two equations are equal and opposite
I would use fminsearch for this. See below. Note that I am using abs(A - B) for the Error term. % minimize error between two ...

Show only a part of the yaxis
Here is a kind of messy workaround. Note that this doesn't work if you have the grid on. h = plot(linspace(-2, 2, 1000), atan(...

| accepted

Smooth curve in certain regions to get desired output
Maybe you can adapt this approach to get what you want. This uses two different moving average filters for the start and end of ...

| accepted

How to model secant and cosecant in Simulink
If I remember correctly, there is only one "Trigonometric Function" block in Simulink. Just double click the block and change t...

Why is the number of periods of a cosine wave in the plot changing with the number of samples ?
This is called aliasing. I recommend reading the linked Wikipedia article. The sample rate (in this case the number of time sam...

| accepted

Plot with x-axis limits going from [180:360] then [0:180] contiguously
It seems extremely odd that your data would "wrap" at 250 degrees. Nevertheless... elevation = [26:80 0:25]; azimuth = linspa...

another crazy plot layout with zoomed portions and arrows
Hopefully you can adapt this approach to your needs. x = linspace(0, 10, 1000); y = exp(-x); plot(x, y) grid on ax = axes('...

| accepted

A little help with translating a piece of Fortran code to Matlab
The easiest way to read a file line by line in Matlab is with the readlines function. Example: str = readlines('test.txt')

subplot with 1 large and 2 small figures
Yes it is. Here is an example. See the documentation for tiledlayout. tiledlayout(2, 2) nexttile([1 2]) % first plot spans tw...