Community Profile

photo

Les Beckham


Last seen: Today
83 total contributions since 2013

Contact

Les Beckham's Badges

  • Knowledgeable Level 3
  • First Review
  • 6 Month Streak
  • Thankful Level 1
  • First Answer
  • Solver

View details...

Contributions in
View by

Answered
"Colon operands must be all the same type, or mixed with real scalar doubles" error I'm trying to run excel file into Matlab function
Well there are several things wrong with this code. You can't use size() to extract things from an array. Replace frq= size(Si...

20 jours ago | 0

Answered
How to plot phase plane only using trajectory equation?
Try something like this: c1 = 1; % replace with your desired constants c2 = -1; t=linspace(0, 10, 500); % adjust for your ...

20 jours ago | 0

Answered
Sum the digits of a number?
I know it sounds too easy to be true but this manipulation is actually the same as modulo 9. No loops or string conversions need...

28 jours ago | 2

Answered
How to find a unexpected high value and turn it to zero?
Here is a way to do this without a loop (using logical indexing) A = [2 3 4 2;5 6 7 3;8 9 0 6; 5 6 1 80;2 3 8 5;3 5 13 4] idx ...

environ un mois ago | 0

| accepted

Answered
How to block out code in Live Script
%{ a = 1; b = 2; %} c = 3;

environ un mois ago | 0

| accepted

Answered
How to include a vertical line at the sample when instant of landing
When I run your code, I don't get the error you cite on line 54. That seems to work fine. The only issue I found was when dete...

environ un mois ago | 0

Answered
I used to be able to see "Command Window" and "Command History" at the same time, now I must switch back and forth?
If you bring the Command History to the top you can grab the top edge of that window (where the title 'Command History' is) and ...

environ un mois ago | 0

Answered
how to print a table
This should be close to what you want. However, I have used the logical not, and, and or functions which appear to be diffferen...

environ un mois ago | 0

| accepted

Answered
Run a code for 100 years
I don't think the results are going to be very interesting but you could do what you are asking as follows: ro=1.49e11; ...

environ 2 mois ago | 0

| accepted

Answered
Using Inequality in a For loop
Walter has correctly shown how to express mutiple inequality conditions in Matlab (you must include the & (and) operator). Howe...

environ 2 mois ago | 1

| accepted

Answered
how to fill between 2 graphs
What do you mean by "fill the gap"? Do you want to connect the start and end points so that this becomes a closed curve? If so...

environ 2 mois ago | 0

| accepted

Answered
Store matrices under different variable names within a loop?
Make A a 4x4x4 three-dimensional matrix instead of creating multiple 4x4 matrices: mat = randi([0, 9], [4,16]) A = zeros(4,4,4...

environ 2 mois ago | 2

| accepted

Answered
Fill command issue for time series
Based on your sample data, you need to make a simple change to your code. Since your vectors are columns, you need to concatena...

environ 2 mois ago | 1

| accepted

Answered
Creating an array with exprnd numbers
Try this: A = zeros(100, 2); mu = 5; % or whatever you want for the mean of the distribution A(:,1) = exprnd(mu, size(A(:,1))...

2 mois ago | 0

| accepted

Answered
when a save figure , the numbers appear in the name of the png with e+0X
Change your format spec to '/Figures/Distance_%d@%.3f.png' You might want to read up on the documentation for this: https://w...

2 mois ago | 1

| accepted

Answered
How to get a variable value in the gain block. This variable value is defined in a Matlab function block.
To do this, I would use a Multiply block instead of a gain block. Make x an output from your Matlab function block. Connect th...

2 mois ago | 0

Answered
How to quickly find the first non-zero element without iterations in all columns in a sparse matrix?
Try this. In my test with a 1000x1000 random sparse 0 or 1 matrix (A = sparse(randi([0 1], 1000, 1000));) it is about 4 times f...

2 mois ago | 0

Answered
can some xxplain what the following program does? Thank youuuu!: peso=5000; while (peso > 0) disp (‘I order another coffee’); dollar = dollar – 250; end disp (‘I finished drinking
Per Stephens comment, I'm repeating my comment as an answer (with some additions). This script does pretty much nothing other t...

3 mois ago | 1

Answered
How can i discretize a signal within simulink?
Look at the ZOH (https://www.mathworks.com/help/simulink/slref/zeroorderhold.html) and Unit Delay (https://www.mathworks.com/hel...

4 mois ago | 0

Answered
How do I find maximum value of n so that 2^n is less than a value (ex, 500?)
I think you may be looking for log2. Documentation available here: https://www.mathworks.com/help/matlab/ref/log2.html

4 mois ago | 0

Answered
Diagonal matrix, wishing to solve Ax=b
I thought that I had commented on this question earlier with something that should work for you. Here is the code that I think ...

4 mois ago | 0

Answered
help with inefficient code
Try this. There may be a more efficient approach but I'm pretty sure this will be faster than what you have now. T1.time = [ ...

4 mois ago | 0

| accepted

Answered
Array indices must be positive integers or logical values.
The error text pretty much explains why you are getting an error. "Array indices must be positive integers or logical values" ...

5 mois ago | 2

| accepted

Answered
How can I know if my laptop is plugged into AC power via Matlab?
That error message (''pmset' is not recognized as an internal or external command, operable program or batch file) is a Windows ...

6 mois ago | 1

| accepted

Answered
Extracting a value from a 3D table
A 3d example using Matlab's indexing functions instead of floor and rem: t3=[1 2 NaN; 4 5 6; 7 8 9]; % a 2d matrix with one N...

6 mois ago | 0

Answered
Legend not working with plot (just have some incorrect colors)
If you make the 'for radius = r' loop the inner loop instead of the outer loop, you should get what you want. What is happeni...

plus de 2 ans ago | 0

Answered
I would like to evaluate a function for N=11,21,51,and 101 using a for loop, but I can only get it to do the last N.
You will need to use an array to store the four different df results. Since your df is going to be different sizes depending on...

plus de 2 ans ago | 0

Answered
How do I fix Invalid first data argument ?
The plot() function requires variables as arguments, not a character vector (which is what you have created by putting single qu...

plus de 2 ans ago | 0

| accepted

Answered
How to remove markers in plot at specified places?
If the goal is to remove all of the markers except for the 'outer' ones, then try this. This should be relatively generic (inde...

plus de 2 ans ago | 0

| accepted

Answered
My Function is supoosed to return 55 when i call it with 10 based off of pyramid sum. However my function gives me 20. Please help
The *main* problem with this code is that you are using the same variable for the loop index and for accumulating your result. ...

plus de 2 ans ago | 1

| accepted

Load more