Answered
Making a 3d array with an index that unifies all three layers
x = your 3d array k = your index result = x(k,k,:); % the three pieces of info at index k or, depending on how you wa...

8 years ago | 0

| accepted

Answered
Create a row vector with specific condition
What's wrong with the first method you propose? rowVect = [x y y y y y]; If you want to generalize it (maybe you don't k...

8 years ago | 2

| accepted

Answered
How can I pass an array as argument to a function; and update the contents of the array and return it to the calling function. how do I do it?...Can anyone help me? Thanks in adbvance
In the caller: x = myfunction(x); In your function: function x = myfunction(x) x = whatever;

8 years ago | 0

| accepted

Answered
Why do i keep getting Index exceeds matrix dimensions and that there is an error in my dx(3) line
You don't tell us how you are calling ode45 (I presume), so we can only assume that the incoming state vector x has only two ele...

8 years ago | 0

Answered
Access current value ode45
Some issues with your code: 1) You don't pass the state vector into your derivative routine! E.g. in this line: [t,x]=od...

8 years ago | 0

| accepted

Answered
Using end as argument to function
Weird, but it does match the doc for end: _"... end = (size(x,k)) when used as part of the kth index ..."_ E.g., >> f...

8 years ago | 0

| accepted

Question


R2018a complex interleaved data is the new memory model
This is a heads up for mex programmers that work with complex data. According to the Release Notes, it appears that MATLAB R2018...

8 years ago | 2 answers | 0

2

answers

Answered
Solving Coupled ODE's with Runge Kutta.
Do it the same way the examples for ode45 do it in the doc. Let your state vector be two elements with y(1) = your original...

8 years ago | 0

Answered
Standard arithmetic operators and interleaved complex numbers in mex
It looks like you need to work with the real & imag data elements individually from this page of the doc: <https://www.mathwo...

8 years ago | 0

Answered
Standard arithmetic operators with interleaved complex API?
It looks like the latter from this page of the doc: <https://www.mathworks.com/help/matlab/matlab_external/handling-complex-d...

8 years ago | 0

Answered
MEX Fortran routines crashing
*NEVER, EVER* use literal integer constants as input arguments to the MATLAB API library functions in Fortran! You can never gua...

8 years ago | 0

Answered
A good way to test uniform random number
Not sure what the real goal is here. There are lots of uniform random number generator tests that you can use, and you will get ...

8 years ago | 0

Answered
How to run saved code?
Generally you simply copy the unzipped files to a folder that is on the MATLAB path (e.g., your current working folder). Then MA...

8 years ago | 0

Answered
im not getting the following error .Matlab file is attached
You could get this error if im_n is a matrix that does not have im_sz(2) number of columns.

8 years ago | 0

| accepted

Answered
I have been assigned homework that ask me to make a script that calls a function. The function is a separate file from my script. I would like to know how to do this.
E.g., in your script file, you should have a line that looks something like this: y = MoveAve(x); % x is the input and y is...

8 years ago | 0

| accepted

Answered
Two Stage Rocket zeroing a value and indices must be a positive real interger?
In this line: hs13 = hs1bo+vs1bo(t1-ts1bo)-0.5*g0*((t1a-ts1bo).^2); This vs1bo(t1-ts1bo) was probably meant to b...

8 years ago | 0

Answered
Decimal numbers in a triple for loop
Have you inadvertently created a variable with the name 'exp' in your workspace? If so, clear it and don't use that name for a v...

8 years ago | 0

Answered
How to find the minimum value in a row of an array that is not equal to zero
B = A; B(B==0)=inf; result = min(B,[],2);

8 years ago | 0

Answered
how i convert (0.345346329292023) to 1-sqrt(3/7)
I don't think you are going to be able to do this in general. The Symbolic Toolbox can help with some simple forms involving squ...

8 years ago | 1

Answered
Good Day Sir/Ma'am. May i ask what is the meaning of ode45 here and @dfunc? --------> [t,x] = ode45(@dfunc, tspan, x0);
ode45 is a numerical integration routine doc ode45 @dfunc is a function handle that points to a function called dfunc. T...

8 years ago | 0

| accepted

Answered
How do I solve the differential equation numerically which is of the form : (z"/[1+(z')^2]^(3/2))+(0.1928529/x)=2+(50.99203)*z ? I need to get the x and z values.
Start with this: (z"/[1+(z'​)^2]^(3/2)​)+(0.19285​29/x)=2+(5​0.99203)*z Solve for the highest order derivative z" z...

8 years ago | 0

| accepted

Answered
For and Break Stuck
It is often better to use tolerances for floating point comparisons, unless you wrote the underlying code and you *know* that th...

8 years ago | 0

Answered
Simple Method for Finding if ANY NaN values occur in a matrix.
Short of a mex routine that can avoid the creation of a potentially large intermediate array, I think you are stuck with isnan( ...

8 years ago | 2

| accepted

Question


When I first learned programming ...
Tell your early programming stories here! Here is one of mine ... I attended a small college in Idaho (now Northwest Nazaren...

8 years ago | 3 answers | 1

3

answers

Answered
Adding a variable to a square zeros matrix given x and y coordinates calculated from separate vectors
It is unclear what the M matrix is supposed to be, but is this what you need? M(classpos,truepos) = 1;

8 years ago | 1

| accepted

Answered
Error-"Index exceeds matrix dimensions"
You need to examine A and determine why it is not the size you expected. E.g., at the command line type this: dbstop if err...

8 years ago | 0

Answered
Parse error in function
Separate those two statements. E.g., this outer_rad = inner_rad && inner_rad = outer_rad; should be this temp = out...

8 years ago | 0

| accepted

Answered
how can i use randperm without involving a certain unknown number.
One way: n = 10; N = 1:n; x = randi(n); N(x) = []; p = N(randperm(numel(N),2));

8 years ago | 1

Answered
how to add 2 to some of array's elements?
a(3:end) = a(3:end) + 2;

8 years ago | 2

| accepted

Answered
Simultaneous solving of the system of ordinary differential equations
The doc for ode45 shows examples of 2nd order ODE systems. E.g., look at this link <https://www.mathworks.com/help/matlab/ref...

8 years ago | 0

| accepted

Load more