Answered
Sum of sequence with accuracy
exp(-x) will calculate that sum.

6 years ago | 1

Answered
Need help solving this problem with newtons method
To match how you are calling it, you need to switch the order of the arguments in this function handle: F = @(p, t) k*p*(L-p)-a...

6 years ago | 0

Answered
Operators "concatenation" ?
No. MATLAB syntax does not allow using ( ) or { } right after a function call. You could of course create a third function to d...

6 years ago | 0

| accepted

Answered
Time of sparse matrix components allocation
Every time you add even one element to a sparse matrix, it has to copy data ... perhaps all of the current data ... to make room...

6 years ago | 0

Answered
How to get matrix data from function ,anyone help me
Not sure what the real question is. Maybe this does what you want? function [apZ,atZ]=example(a,Z) apZ = a + Z;...

6 years ago | 0

| accepted

Answered
Order a string row based on another string row by matching each element (like the sort function does)
One way: [~,idxb] = sort(B1); [~,idxa] = sort(idxb); A1new = A1(idxa); A2new = A2(idxa);

6 years ago | 0

Answered
How to get multiple roots of x
How are you solving it now? Maybe you just need to feed your method different starting guesses.

6 years ago | 0

Answered
Future Bank Account Balance
This line overwrites your old balance vector with a scalar oldbalance = newbalance(i); Instead of keeping track of old balance...

6 years ago | 0

| accepted

Answered
How to compare elements with above and below element in a column?
Is this what you want? for T = 2:M if( abs(A(T,4) - A(T-1,4)) > 50 ) A(T,4) = 0; end end

6 years ago | 0

| accepted

Answered
How do I single out elements in a vector?
Hints: You might look at the mod( ) or rem( ) function to determine if values are even. To determine how many are even, you cou...

6 years ago | 0

Answered
Matlab crashes while running MEX Fortran 90 routine
Three comments: 1) You should NEVER, NEVER, NEVER pass literal integers into mex API functions. It can often be the case that ...

6 years ago | 0

| accepted

Answered
Troubles with data types: integers, doubles, scientific notation, and type casting
You are confusing integer "types" with integer "values". Integer types are int8, uint8, ... int16, uint64. Integer values a 1,...

6 years ago | 0

Answered
Error using * Inner matrix dimensions must agree.
Use element-wise operators (with the dot .) instead of matrix operators (without the dot .), e.g., x1= 1 - (exp(-(t/4))).*(cos(...

6 years ago | 0

| accepted

Answered
Cant Use Reshape Function with Randi or Randperm
I'm guessing you need to tell this dec2bin call that it always needs to produce 16 digits also: permboxin_temp = dec2bin(permbo...

6 years ago | 0

Answered
Using for loop to match generated random numbers to an input value
Since you don't know ahead of time how many tries it will take, this is best done with a while loop instead of a for loop. E.g.,...

6 years ago | 0

| accepted

Answered
How can I append a new cell onto the end of a Cell Array?
If F really is a cell array in the format you list, then just C(end+1) = F; If not, then you may have to do this: C(end+1) = ...

6 years ago | 0

| accepted

Answered
Nonscalar arrays of function handles are not allowed; use cell arrays instead.
You don't need to create an array of function handles. You just need to construct one function handle to use for that iteration....

6 years ago | 0

| accepted

Answered
Forward Euler method for Higher order differential equation
You need to think of Y as your three element column vector as you have defined. So at each step you are dealing with a column v...

6 years ago | 1

| accepted

Answered
Subscript indices must either be real positive integers or logicals while k starts from 1 .
The RK4( ) function expects to call the derivative function with the signature F(tt,y), i.e. time is the 1st argument. But your...

6 years ago | 1

Answered
My matrix should be symmetric but isn't by a ridiculous margin
Welcome to the world of floating point arithmetic. This is typical and not unusual behavior. https://www.mathworks.com/matlabc...

6 years ago | 0

| accepted

Answered
Plot a 100x100 grid of 1's and 0's
Another option: b = your binary matrix spy(b);

6 years ago | 0

Answered
“Dimensions of arrays being concatenated are not consistent”
TYpe this at the command line: dbstop if error then run your code. When the error occurs the code will pause with all current ...

6 years ago | 0

Answered
ODE45 randomly returns vector of length 1.
Try clearing your variables before you run the script. It could be that you are inadvertently using a variable from a previous i...

6 years ago | 0

Answered
Solving System of 1st Order ODEs with Euler's method
The easiest way is to treat your y as 2-element column vectors instead of scalars. E.g., % function file function [x, y] = od...

6 years ago | 1

| accepted

Answered
Cell Array, Example From Manual
The variable C is only a 2D variable having two dimensions. You have requested indexing into a third dimension with that last...

6 years ago | 0

| accepted

Answered
sum every n columns, element by element
m = your matrix n = number of columns to sum squeeze(sum(reshape(m,size(m,1),n,[]),2))

6 years ago | 1

| accepted

Answered
How do I get rid of a dimension of length 0 in a multi-dimensional array?
A variable that has a 0 dimension is an empty variable ... there is no data in it to reshape. You need to backtrack in your cod...

6 years ago | 0

| accepted

Answered
ode euler - explicit method
Add this after each figure statement hold on

6 years ago | 0

| accepted

Answered
Monte Carlo Simulation - pair of dice roll
You are supposed to count the number of rolls it takes to get boxcars, not the number of boxcars you get in N rolls. So for eac...

6 years ago | 0

| accepted

Answered
How to concatenate two time arrays with the same time step?
Ttotal = [t1,t1(end)+1+t2];

6 years ago | 1

| accepted

Load more