Answered

How can one extract a column based on a value of another column?

>> A = [ 0 1; 1 0; 0 2]; >> A_0 = A(A(:,1)==0,2) A_0 = 1 2 >> A_1 = A(A(:,1)==1,2) A_1 = 0

How can one extract a column based on a value of another column?

>> A = [ 0 1; 1 0; 0 2]; >> A_0 = A(A(:,1)==0,2) A_0 = 1 2 >> A_1 = A(A(:,1)==1,2) A_1 = 0

1 month ago | 0

Answered

How to reduce decimal point in .dat file?

For your two alternative ways of saving this data into a text file, try the following two options. Please read the documentatio...

How to reduce decimal point in .dat file?

For your two alternative ways of saving this data into a text file, try the following two options. Please read the documentatio...

1 month ago | 0

| accepted

Answered

How do I plot a scatter plot where the x is the position of the element in a vector and the y is the value of the element in the vector?

A = [1; 6; 2]; scatter(1:length(A), A);

How do I plot a scatter plot where the x is the position of the element in a vector and the y is the value of the element in the vector?

A = [1; 6; 2]; scatter(1:length(A), A);

2 months ago | 0

| accepted

Answered

Hex to binary character array

This string is way too long to be converted to a decimal (or binary) number directly. It is actually 100 hex digits long (not 1...

Hex to binary character array

This string is way too long to be converted to a decimal (or binary) number directly. It is actually 100 hex digits long (not 1...

2 months ago | 1

| accepted

Answered

using fget1 to read text file. Need help sorting data

The link that Walter provided looks promising. If you wish to pursue the processing on your own, here is a script that will rea...

using fget1 to read text file. Need help sorting data

The link that Walter provided looks promising. If you wish to pursue the processing on your own, here is a script that will rea...

2 months ago | 1

| accepted

Answered

What is wrong with this code?

If you are trying to plot the step and impulse responses of your transfer function you need to call step() and impulse() as func...

What is wrong with this code?

If you are trying to plot the step and impulse responses of your transfer function you need to call step() and impulse() as func...

2 months ago | 0

Answered

How to have a string change based on user input

I've not tried accessing this data source or running your code, but I'm pretty sure that you need to change the following lines ...

How to have a string change based on user input

I've not tried accessing this data source or running your code, but I'm pretty sure that you need to change the following lines ...

2 months ago | 1

| accepted

Answered

What goes before this?

You can change your 'Stuff =' line to the following: Stuff = sprintf('%s %s is the %d day of the year.', Month,Date,N); Or, yo...

What goes before this?

You can change your 'Stuff =' line to the following: Stuff = sprintf('%s %s is the %d day of the year.', Month,Date,N); Or, yo...

2 months ago | 0

| accepted

Answered

Changing amount of decimals in between loops

Just index into the vector that you created that specifies the number of places to which you wish to round for that iteration in...

Changing amount of decimals in between loops

Just index into the vector that you created that specifies the number of places to which you wish to round for that iteration in...

3 months ago | 0

Answered

How can I scope using degrees insted of seconds?

The Simulink Scope block always uses simulation time as the x axis. If you wish to plot two simulation signals against each oth...

How can I scope using degrees insted of seconds?

The Simulink Scope block always uses simulation time as the x axis. If you wish to plot two simulation signals against each oth...

3 months ago | 1

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...

"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...

4 months 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 ...

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 ...

4 months 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...

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...

5 months 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 ...

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 ...

5 months ago | 0

| accepted

Answered

How to block out code in Live Script

%{ a = 1; b = 2; %} c = 3;

How to block out code in Live Script

%{ a = 1; b = 2; %} c = 3;

5 months 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...

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...

5 months 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 ...

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 ...

5 months 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...

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...

5 months 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; ...

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; ...

5 months 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...

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...

5 months 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...

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...

5 months 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...

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...

6 months 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...

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...

6 months 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))...

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))...

6 months 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...

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...

6 months 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...

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...

6 months 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...

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...

6 months 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...

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...

7 months 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...

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...

7 months 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

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

7 months ago | 0