Answered
Why are properties of unique objects referring to the same object?
What is the desired behavior of the classes you are defining? Variables derived from the handle class are _supposed_ to share pr...

8 years ago | 0

Answered
What is the equivalent of "extractAfter" function in MATLAB R2016a?
Maybe write your own replacement. E.g. a bare bones code with very little error checking: function newStr = extractAfter_(s...

8 years ago | 2

| accepted

Answered
()-indexing must appear last in an index expression.
You can't daisy-chain indexing onto the end of a function return variable. E.g., this wsys = welch( mean(tsys)(:), win ); ...

8 years ago | 0

Answered
Dos varargout make a copy of the output variables?
To see how MATLAB returns variables from subroutines you can run the following code: function x = junkdemo(n) x = rand(n...

8 years ago | 2

| accepted

Answered
What is the error in this code.
Did you mean: result = 1 + e;

8 years ago | 0

Answered
Can we do matrix operations on a matrix that might contain NaNs in it?
You can do any operation you want with the matrix, but the NaN's will propagate through all of the calculations. That is, in ge...

8 years ago | 0

Answered
conditional adding of elements to an array
A = your data vector n = whatever (e.g., 50) result = cell2mat(arrayfun(@(x)[repmat(n,1,floor(x/n)),rem(x,n)],A,'uni',fa...

8 years ago | 0

| accepted

Answered
Creating a matrix that is more time efficient
C = 3*A - B(:); % or C = bsxfun(@minus,3*A,B(:)) C(1:n+1:end) = 5*B + A;

8 years ago | 1

| accepted

Answered
How to eliminate Nan
result = the stuff you are currently doing result(isnan(result)) = [];

8 years ago | 0

Answered
Solving equation with increasing value by multiplication
a = 2.^(1:7);

8 years ago | 0

Answered
How to load data from one script to us to plot on another?
Put the variables you want passed as outputs of the first function and inputs to the second function.

8 years ago | 0

Answered
returning string array from mex
String arrays are a type of classdef object. They don't have any public properties that you can get at, so at present there is N...

8 years ago | 1

| accepted

Answered
Backwards/Reverse in "Direct" For Loop
for k=numel(A):-1:1 k would have the values 4, 3, 2, 1 in turn. So indexing using A(k) you would be accessing A(4), A(3), A...

8 years ago | 1

Answered
For a value 0<i<=4 give k=1, 4<i<=8 give k=2 and so on
You don't really need the lower bounds on your tests if you have already failed the previous test. E.g., if i <= 4 k...

8 years ago | 0

Answered
Make a vector out of all even/odd numbers from 1 to 100 using for and if
You probably have left-over variables from a previous run that you are writing into. Clear them out first. E.g., put this at the...

8 years ago | 1

Answered
How can I write a program that indicates a number if it is integer or not?
doc floor doc ceil doc round What happens if you use one of these functions and compare the result to the original va...

8 years ago | 0

Answered
Flip a vector using for
Because you are exchanging elements, you wind up flipping the vector twice, which gets it back to the original state. Instead, j...

8 years ago | 0

Answered
Convert String array into Cell array
Is this the conversion you need? result = arrayfun(@(x)char(varNames(x)),1:numel(varNames),'uni',false);

8 years ago | 2

| accepted

Answered
Convert days to years month and days (leap year issue)
E.g. the_date = '1900-01-01'; the_days = 10; result = datetime(the_date) + the_days; Then to get at the individual...

8 years ago | 1

| accepted

Answered
What is the diffence between end and return in function ?
If the "end" you are talking about is the function end, then there is no difference. Both statements will cause a return to the ...

8 years ago | 1

Answered
Shift left and replace the LSB bit?
bu = your char array result = bu(:,2:end); result(:,end+1) = new_bit_char; E.g., >> bu = char((rand(5,8)<0.5)+'0...

8 years ago | 0

| accepted

Answered
Eulers for two degree spring system
You don't have enough equations in your code. This is a 4th order system (Two variables each as a 2nd order ODE gives 2x2 = 4 or...

8 years ago | 0

| accepted

Answered
Can someone please help me with this mechanical engineering problem? Thanks so much
Maximizing profit is the same thing as minimizing cost in your case. So you can use a method that minimizes a cost function. But...

8 years ago | 0

Answered
I am facing problem with the code which i giving below.
This looks like your initial conditions are in degrees: theta0 = [30 0]; But the code assumes the input is in radians be...

8 years ago | 0

Answered
Using ode45 to solve matrix/vector form of state space diff eq
Trying to understand your nomenclature, and using your element ordering, here is the layout I would normally start with for a 4-...

8 years ago | 0

Answered
How to take an average of three dimensional data?
x = your 3D matrix result = mean(reshape(x,360,720,12,5),3);

8 years ago | 2

| accepted

Answered
How to check if a user input is between a certain range
Use an "if test" combined with the results of the expressions z > 0 and z < 1 (or possibley z >= 0 and z <= 1 depending on what ...

8 years ago | 0

Answered
Accessing variables with functions in Matlab
To have a function change a variable in MATLAB, one would typically do this: x = myfunction(x); And then the body of myf...

8 years ago | 0

| accepted

Answered
How to get the user to input numbers that will then go into an array?
You can use the input( ) function: <https://www.mathworks.com/help/matlab/ref/input.html?searchHighlight=input&s_tid=doc_srch...

8 years ago | 0

Answered
how can i generate real random numbers?
See this FEX contribution by John D'Errico: <https://www.mathworks.com/matlabcentral/fileexchange/49795-randfixedlinearcombin...

8 years ago | 0

| accepted

Load more