Answered
Plot every nth data point
v = your vector t = 1:numel(v); plot(t(30:30:end),v(30:30:end)); % <-- assuming you want to start at 30th element

8 years ago | 3

Answered
Counting active binary combinations
You are choosing a combination of 64 bits taken 8-to-16 at a time. So add them up: s = 0; n = 64; for k=8:16 ...

8 years ago | 1

| accepted

Answered
Numeric array values replaced with zeros
This is just a display issue. The values are still there. E.g., >> x = [-3 10 1e9 4 300] x = 1.0e+009 * -0....

8 years ago | 0

| accepted

Answered
How can I overwrite a variable saved in a script that I have to loop with a different value?
Edit the script file blabla.m, and comment out the a = 18 line: % a = 18; Also, make sure the script file blabla.m does ...

8 years ago | 0

Answered
Can I assign values to an array in a diagonal direction from a reference point on that array?
Yet another method: [M,N] = size(X); n = min(M,N); XXX = repmat(X,3,3); % work with a big matrix so we don't have to...

8 years ago | 0

Answered
How to accept user input in a lowercase and uppercase?
One approach: switch lower(handles.metricdata.CNO) Then adjust your case conditions to be strictly lower case.

8 years ago | 1

| accepted

Answered
Why does this matrix contain different values depending on how it is accessed?
This sparse matrix is invalid. The SPOK utility from the FEX by Tim Davis reveals the problem: >> spok(A) Warning: 2 jumbled r...

8 years ago | 2

| accepted

Answered
I am not seeing what is wrong with my code, I've checked doc and help.
You have an inadvertent return statement: else b = c; return <-- get rid of this line The way you h...

8 years ago | 2

Answered
Can I pull a single character froma string?
See this link for getting substrings from strings: <https://www.mathworks.com/matlabcentral/answers/351195-manipulating-strin...

8 years ago | 1

Answered
What is the syntax error in this?
Each comment section on a line needs to start with the % character. The C/C++ style of commenting with // does not work with ...

8 years ago | 1

| accepted

Answered
I am trying to write a function that will solve ODE's by Runge Kutta's method.. What is wrong in my code?
This s3=f(t+h, y+h*s2); should have x in that first argument, not t. E.g., s3=f(x+h, y+h*s2); And this y...

8 years ago | 0

Answered
datetime error/inconsistency
This inconsistency has been noted before in previous posts. E.g., with datenum you get the same answer with month=0 and month=1...

8 years ago | 0

Answered
Could someone please help me trouble shoot the following ode45 code. New to Matlab. Showing multiple errors. Thanks a lot
In your function handle, you are indexing into the d variable with f = @(t,x) [(d(etc... But you have defined d as a sca...

8 years ago | 0

| accepted

Answered
Im trying to find the absolute value of the difference between current value 'c' and the values 'n'.
Change n(1,i) to n(i). n is a column vector but you are indexing into it as if it were a row vector. You could use n(i,1), but...

8 years ago | 0

Answered
How do I append rows and columns into a 3 x 3 Matrix
Ice = [Ice, Avgcol Avgrow, 0 ];

8 years ago | 0

Answered
resize cell in different dimension
Assuming you mean you want to reshape the cell array itself, and not the _contents_ of the cell array: mycell = your 20x1 c...

8 years ago | 1

Answered
Why aren't global variables behaving as they should across C-Source files with a common header using mex?
Coding technique advice: When you have top-level global variables shared among multiple source files, I like to have all of the...

8 years ago | 0

Answered
How to limit the number of for Loops while executing while loops?
In your while loop: while number_of_repeats <= 3 The condition "number_of_repeats <= 3" is always true because the for-lo...

8 years ago | 0

| accepted

Answered
How would I suppress function answer and move the answer to a variable all within the function? Homework
Do you mean call the function and put the result into a variable named s? Like this: s = twosum(4,5);

8 years ago | 1

Answered
Is z an object here? How to interpret the code?
z is a struct. It has a field named "mean".

8 years ago | 0

Answered
I'm trying to save my script however when i click the green arrow it seems to display an error message. What should i do?
Click the black/blue square disk icon in the upper left to save the file. Clicking the green arrow simply runs the file (and if...

8 years ago | 0

Answered
How do I write the function to derive an nth taylor polynomial?
You are using the series expansion for cos( ), not the series expansion for exp( ). You need to replace the terms you are using...

8 years ago | 0

| accepted

Answered
How to convert the results to a vector?
Form your loop differently. Loop over the indexes of x, not the values of x. E.g., for i=1:numel(x) y(i) = sin(x(...

8 years ago | 0

Answered
adding elements from cell array to another
m = cellfun(@(A,B)[A B],m,y,'uni',false);

8 years ago | 0

| accepted

Answered
Imag, real function error
It could be that you have inadvertently created variables with the name "real" or "imag" that are shadowing the functions real a...

8 years ago | 0

Answered
generating random values from another matrix with a random value in rows only
Is something like this what you want? Randomly distributed values from X but staying in same column? X = whatever rows ...

8 years ago | 0

| accepted

Answered
Write a MATLAB script and user defined function that solves the following orbital equation of motion using ode45
Your code is not even remotely close to what it needs to be for this. In the first place, since you have a 2nd order ODE in 3-s...

8 years ago | 0

| accepted

Answered
Newton's Method for a polynomial equation
You need to create function handles for your functions. As written, MATLAB thinks you are trying to evaluate the functions at a...

8 years ago | 0

| accepted

Answered
Derivative in function handle
E.g., if you want function handles you could get at them with the symbolic toolbox >> syms x >> f = @(x) x + log(x) f...

8 years ago | 1

Answered
how to extract another matrix out of a big matrix
v = [420,422,425]; B = A(ismember(A(:,1),v),:);

8 years ago | 1

| accepted

Load more