Answered
How do I code matlab to recheck while loops before continuing?
Maybe something like this logic is what you need, although you don't specify a way to get exe set to 0 so you would have to add ...

8 years ago | 0

Answered
Having trouble getting function to return two values
Your code has a path where nothing gets assigned to the output variables. Also, even for the path that does assign the output va...

8 years ago | 0

Answered
How to use Euler method with IVP with function of x and y?
3x is not a valid MATLAB expression. You need to have the multiplication operator between the 3 and the x. Also, you need to use...

8 years ago | 1

| accepted

Answered
How to count the number of consecutive repetitions of an array?
E.g., [r,s] = runlength(A,numel(A)); result = r(logical(s)); You can find runlength on the FEX: <https://www.mathw...

8 years ago | 1

| accepted

Answered
Physics problem help!
So, I will give you a start for an Euler scheme. You have two states to keep track of, the position and the velocity. Define two...

8 years ago | 0

Answered
code is showing error with some inputs
Why are you using v(1:1) as an index into v? Did you mean this instead? w = v(end:-1:1); Also, it is not clear from you...

8 years ago | 0

| accepted

Answered
Confusion in using polyfit and polyval to predict data
Because that is the "time unit" used for your polyfit calls earlier in the code: nz_years_adjust=(nz_years-1900)/50; I.e...

8 years ago | 1

| accepted

Answered
Conversion of seconds to date
MATLAB is giving you the result of June 16, 2010 because that is the correct answer for the input of 1907798400. This matches in...

8 years ago | 5

| accepted

Answered
How to separate cell rows in different cell??
Do you mean like this? A = yourcell(1,:); B = yourcell(2,:); : etc But if you have lots of rows to deal with...

8 years ago | 0

| accepted

Answered
Round down lowest number in a decimal number
E.g., x = whatever result = floor(x*100)/100;

8 years ago | 1

| accepted

Answered
Copying dynamic array to MxArray object using memcpy in c++
Two fundamental problems: 1) You can't guarantee that successive calls to calloc( ) will produce memory segments that are adj...

8 years ago | 0

| accepted

Answered
How can I find roots of cubic function?
Do you mean like this? syms x y solve('y^3 - (x+50)*y^2 +(500*x -5200)*y + (3600*x) = 0',y)

8 years ago | 0

Answered
Fibonacci sequence function problem
The fibonacci( ) function was introduced in R2017a. What version of MATLAB are you running? If you are running an earlier ver...

8 years ago | 1

Answered
Error in fzero function
Use a function handle. E.g., fzero(@(x)x^3+2*a-b,-1)

8 years ago | 0

| accepted

Answered
Hi everyone! I need help!
Maybe adding another sum gets the result you want? y(j,i,k) = sum(sum(Mat (:,:,[k]) == Mat(j,i,k)));

8 years ago | 0

Answered
Bubble sort that stops running when sorted
Typically you have a variable that keeps track of whether you did a swap or not in your most recent loop. E.g., did_a_swa...

8 years ago | 0

| accepted

Answered
What happen with my code????, please help me fix this!!
See if this link helps you understand what is going on with your floating point calculations: <http://matlab.wikia.com/wiki/F...

8 years ago | 0

Answered
Create a matrix with letters
Is this what you want: A = [sym('m%d',[n 1]) sym('x%d',[n 1]) sym('y%d',[n 1]) sym('z%d',[n 1])]

8 years ago | 0

Answered
Converting Hexadecimal values to Ascii Text
E.g., using the char( ) function: >> h = '41' h = 41 >> d = hex2dec(h) d = 65 >> c = char(d) c = ...

8 years ago | 1

Answered
problem while applying bisection method "Undefined function or variable 'vbr'
vbr needs to either be a function file (i.e., a file named vbr.m on your MATLAB path), or more likely you should pass that into ...

8 years ago | 0

Answered
Reshaping/vectorizing a n-d matrix to a vector along each dimension
result = reshape(permute(a,[3 2 1]),[],1);

8 years ago | 0

| accepted

Answered
Generating samples of two dimensional random variable
Y = something Z = something result = rand(Y,2*Z); result(:,2:2:end) = result(:,2:2:end) .* result(:,1:2:end);

8 years ago | 0

| accepted

Answered
Create a matrix with a repetitive pattern
x = your original vector n = number of vertical repititions result = repmat(x,n,1);

8 years ago | 0

| accepted

Answered
Fast computation of 2D summation
T = reshape(B,size(B,1),[]) * A(:);

8 years ago | 0

| accepted

Answered
Getting the nonzero mean of each cell element
Can you do this: mean_value = cellfun(@(x)mean(nonzeros(x)),dot_value);

8 years ago | 0

| accepted

Answered
how to reshape a matrix using for loop
Try switching the m and n in your for-loop indexing, and use (i,j) for your indexed assignment instead of (m,n). E.g., for ...

8 years ago | 0

Answered
How do I create an array of answers for the given program? it gives me an error of "Assignment has more non-singleton rhs dimensions than non-singleton subscripts." How can I fix this?
MU is a vector, so the right hand side is a vector. You can't stuff that into a single scalar spot c(i,j).

8 years ago | 0

Answered
Delete a row from matrix and save the modified matrix as a new matrix?
Ym = Xm; % create a new matrix Ym(3,:) = []; % modify only the new matrix

8 years ago | 1

| accepted

Answered
How can I include the derivative of a function as an input to a function handle?
Currently you have a 3-element state vector, with the states being a, b, c. You simply use a 4-element state vector with the 4th...

8 years ago | 0

Answered
How do I use input to make a string and fprintf to output different parts of the string?
Use the 's' option to read the input as a string. E.g., name=input('enter your name ','s'); Then you can use fprintf wit...

8 years ago | 1

| accepted

Load more