Answered
Substitute out anonymous function
E.g., funs = functions(demand); funs.workspace{1} <-- gets the embedded data in the demand function handle

7 years ago | 0

Answered
Euler's method help
Since your ODE is in terms of t, I would suggest you use t in your code to make it more readable to you. Go ahead and keep n but...

7 years ago | 0

| accepted

Answered
How to multiply efficiently a vector by a matrix with only zeros and ones?
So, as expected, the mex routine didn't save you much and is hardly worth it. The multiplies by 1 really don't cost you very muc...

7 years ago | 0

Answered
Why does my mex-function for linear regression return r-squared values above 1?
I haven't run your code, but just looking at it you are using the worst algorithm numerically with single precision numbers, whi...

7 years ago | 0

| accepted

Answered
how to covert a log number into nature number?
I'm assuming this is the result of some symbolic manipulation? Try converting it to double: result = double( your expressio...

7 years ago | 0

Answered
How do you define a matrix that has random values between two parameters in one column and random values between two parameters in another column?
To generate random values between two floating point numbers, use this formulation with the rand( ) function: a = lower num...

7 years ago | 1

Answered
Test for integer value
See the following: doc fix doc ceil doc floor doc round E.g., for a scalar x if( round(x) == x ) % ...

7 years ago | 0

| accepted

Answered
It is showing the error 'arrays indices must be positive integers or logical values'. The code and the pic of error attached with this question. thank you.
For the error, you can debug by typing the following at the command line and running your code: dbstop if error When the...

7 years ago | 0

| accepted

Answered
joining two matrices by column 1
A simplistic approach assuming 1st column numbers are sorted and do not repeat within each a and b variable: c = unique([a(...

7 years ago | 1

| accepted

Answered
How to fix my function script?
You need to have the step increment and the max calculation _inside_ your while loop. m = x; <-- Use this to initialize up...

7 years ago | 0

| accepted

Answered
Deleting rows in a matrix with condition on its column value
New_LongDataUn(New_LongDataUn(:,11) < 1e-12,:) = [];

7 years ago | 0

| accepted

Answered
Questioning the accuracy of Coupled differential equations with forcing function
It's all 0's because that is the solution. Your derivative function is identically 0's in every spot on every call. Look at your...

7 years ago | 2

Answered
Why it says undefined variable x2
You have x2 appearing on the right hand side of your first assignment, before it has been defined.

7 years ago | 0

Answered
Searching and replacing values in a matrix
You are inadvertently using linear indexing because you don't supply the 2nd index. Change your code to: x(x(:,1)>0,1) = .7...

7 years ago | 1

| accepted

Answered
Understanding a Cholesky Factorisation Algorithim
To see if your supposition is correct, just add this to your for loop and put a break point there: for k=1:j-1 %****% ...

7 years ago | 0

Answered
Using Struct in Matlab
Hints: Suppose myrover is the variable name of your rover. Then myrover.wheel_assembly(1).wheel.mass <-- Mass of wheel #1 ...

7 years ago | 0

| accepted

Answered
i have two binary array 10011 and 01010, i want compare each binary and find the number of different and similar bits?
binary1 = 1st binary char vector binary2 = 2nd binary char vector number_of_similar_bits = sum(binary1==binary2);

7 years ago | 0

| accepted

Answered
Euler method for ODE
In general, you can't "vectorize" this process as you suggest. Since the calculation for y(k+1) depends on y(k), the calculation...

7 years ago | 1

| accepted

Answered
Keep Getting This Error : @(T,X)SECOND_ORDER(T,X,A0,A1) must return a column vector.
This line declares initial state that you pass to ode45 to be a scalar: x0=2; %y So when you call ode45 with x0 it assum...

7 years ago | 0

| accepted

Answered
Is it possible to create a MEX file from C code outside of Matlab?
You can compile the mex routine from outside of MATLAB (e.g., from within Visual Studio), but you will still need the MATLAB lib...

7 years ago | 0

Answered
How to find the center of a circle given two tangent lines and radius using MATLAB?
Find the line bisecting the two tangent lines. This line will contain the center point of the circle. Form a right triangle with...

7 years ago | 3

Answered
Hello. I am new to matlab and I have this problem. I need to store 91 different 3x3 matrices. Yet I get this error 'Subscripted assignment dimension mismatch.' Can someone help me out. Many thanks
You could store them in a 3D array like this: T = zeros(3,3,numel(thetha)); % pre-allocate outside the loop : T...

7 years ago | 0

| accepted

Answered
Help Formatting Relative Velocity Code
<</matlabcentral/answers/uploaded_files/132936/RelativeVelocity.jpg>> Using your picture, I just called the rotational part o...

7 years ago | 0

| accepted

Answered
How can I mxCreateNumericArray with a fixed-point data type?
There is a fundamental difference between the standard numeric types and fixed-point types. The storage for standard numeric...

7 years ago | 0

| accepted

Answered
What is the difference between ( ) and { } when accessing elements of a cell array?
In general if A is a class _whatever_ variable of some size, then A(1) will also be a class _whatever_ variable of size 1x1. I.e...

7 years ago | 4

Answered
solve A*x=B
Sounds like you have inconsistent equations. The A\B calculation is doing the best that it can under these circumstances. E.g., ...

7 years ago | 0

| accepted

Answered
creating a matrix using integers and other matrices
Exactly what you have already written: c = [1,2,a;3,4,b]; What am I missing?

7 years ago | 0

Answered
mxMakeArrayComplex() what's for?
If it is your own low level code creating and manipulating the mxArray variables, then I agree with you that this function proba...

7 years ago | 0

Answered
ODE45, differential equation
Remove the quotes from 'k', and be sure to define k before you call ode45. Also, ode45 is an initial value problem solver, so th...

7 years ago | 0

Answered
Sparse and binary mask
Try this simple C mex routine. It avoids the overhead you are creating with your sparse alternate stuff. Could maybe be improve...

7 years ago | 2

Load more