Community Profile

# Les Beckham

Last seen: Today Active since 2013

Many years developing flight control algorithms and software

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

All

View badges

#### Content Feed

View by

Answered
Get all row indices where values of to columns reach their maximum
A = [1 2 3; 1 4 3; 2 4 3; 1 4 2]; m = max(A(:,2:end), [], 1) Output = find(all(ismember(A(:,2:end), m), 2))

2 days ago | 1

| accepted

Answered
problem with if cycle to determine the datetime
The time returned by datetime('now') will be changing as your code runs, so it seems almost impossible that your if condition wi...

2 days ago | 0

Answered
how to create matrix c, where first column is vector a, and the last column is vector b without a loop
a = [1;2;3;4;5]; c = [a a+1 a+2 a+3] If you are a beginner in using Matlab, I would suggest taking a couple of hours to go ...

2 days ago | 0

Answered
How do i fix the output of my code?
a=rand(2,2) c=1; cmax=2; r=1; rmax=2; while r<=rmax while c<=cmax a(c,r)=round(a(c,r),2); % a(c,r)*100; << y...

4 days ago | 0

| accepted

Answered
Creating Plot with 2 Y-Axis
No there is no way to do that without some manual coding (if only on the command line). But it isn't hard. Here's a simple exam...

10 days ago | 0

Answered
Force 0 tick to appear in a scatter plot
clc, clear, clf n = 0:10; f = n.^2; scatter(n,f, 'k', 'filled') xlim([-1,11]), ylim([-10,120]) ax = gca; ax.XAxisLocation =...

10 days ago | 1

| accepted

Answered
Logical operator not evaluating correctly
I would do this in separate steps. X = randi([-20, 20], [1 15]) Y = zeros(size(X)); Y(X < -5) = -1; Y(X > 5) = 1

10 days ago | 0

Answered
Why are tick marks only on one axis when I change the tick spacing?
Try yticks(-4:0)

11 days ago | 2

| accepted

Answered
Find exceeds array ERROR
One obvious problem with this code is where you try to access pairs(pr,2) but pairs is a one dimensional (4x1) vector. Perhaps ...

13 days ago | 0

| accepted

Answered
one time pad plus randstream
Assuming that the random part of the algorithm is generating the code character vector as you said in one of your comments, some...

16 days ago | 0

| accepted

Answered
how to get no of samples?
If you want a specific number of samples between two endpoints, use linspace instead of the colon operator: n = linspace(9.45, ...

17 days ago | 1

Answered
Next value in alphabet
A simpler approach: char('c' + 1)

18 days ago | 1

Answered
Trying to generate subplot figure
It looks like you have created a variable named figure. Type the following command at your command prompt: which -all figure ...

25 days ago | 0

| accepted

Answered
Save generated text file to user specified path
You can use uigetdir to open a dialog and allow the user to browse for the folder in which to save the file. Read the documenta...

25 days ago | 1

| accepted

Answered
Syntax for pyrunfile with multiple output variables?
This is the way to do that (note that ["A" "B"] is a string array as specified in the documentation for that argument): [A, B] ...

27 days ago | 0

| accepted

Answered
Syntax for pyrunfile with multiple output variables?
Did you try this? [A, B] = pyrunfile("pytorch_model.py", ["A" "B"], X=Xpy, y=ypy) Note that ["A" "B"] is a string array as spe...

27 days ago | 0

Answered
How to shift experimental data (not a function) in a loglog plot?
Instead of adding an offset, multiply to shift the data. I used a factor of 10 as an example. x = [0.015 0.02 0.05 0.1 0.2...

1 month ago | 1

| accepted

Answered
Floating-Point to Fixed-Point Conversion of IIR Filters
The Name=Value syntax for name/value pairs of function arguments only works in r2021a and above. So, changing this: biquad = d...

1 month ago | 0

| accepted

Answered
The Y(:,81) changes linearly with respect to T, I want to modify my code in such a way that when Y(:,81) reaches 2.5E-6 then after that it remains constant through out with T.
Over 100 lines of code to draw a straight line? This plot (with the maximum Y limit applied) can be made in 8 lines of code: T...

1 month ago | 0

Answered
How can I write the coordinates of this geometry?
You don't need a loop. h = 10; th = linspace(pi/2, -pi/2, 100); R = (h/4); %or whatever radius you want x1 = R*cos(th) ; y...

1 month ago | 0

| accepted

Answered
need script to create a block scenario
If you only want to draw a 3x3 grid of 1x1 squares this is pretty easy (see below). If you want the 0.75x0.75 and 0.5x0.5 squar...

1 month ago | 0

Answered
How to approximate float function by integer numbers?
I'm assuming you want to replace the floating point calculation with an integer one? I'm not sure how that is going to "spare s...

2 months ago | 1

| accepted

Answered
How do you create a plot of a function using fplot?
Maybe you want ezplot instead of fplot. Your anonymous function definition syntax is wrong as well. Try this: f = @(t) 5*t.^2...

2 months ago | 0

Answered
How to Set Up If/Else Statement with Condition of Seeing if Item in Structure Array is a Table
I suggest the istable function. Documentation is here

2 months ago | 0

| accepted

Answered
I want to open a tab-delimited XY text file in matlab, use the numerical values of the XY columns to create a matrix and plot the signal.
T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1230202/220812_WT_MO_H134R_EA_1391%20015.txt') sc...

2 months ago | 1

Answered
adding a colormap('jet') to my grapgh please help me
center=[0,0]; %Defining the center of circle ((origin)) %Plotting the first circle at different radius and here i choose from ...

2 months ago | 0

Answered
A table of s versus t.
r=9; omega=100; b=14; t = linspace(0, 0.01, 20) % <<< use linspace instead to generate your t vector % remove the (t) on the...

2 months ago | 0

Answered
Sorting a string according to the values of a vector of type double
It should be as simple as this unless I misunderstand what you are expecting. A = [1.1 2.3 4.4 2.3 5.1]; vegetables = {'carrot...

2 months ago | 0

| accepted

Answered
two while loops running at same time
You can't code them as separate loops and have them run "at the same time". Depending on how you want the timing to work, you s...

2 months ago | 1

Answered
Rounding a decimal down
x = [0.143 0.147]; floor(x*100)/100

2 months ago | 1