Respondida
How to output a mexFunction input without copy
If you are returning a modified variable, then you basically have three choices: 1) Do it the way you were previously doing i...

casi 8 años hace | 0

Respondida
How do I convert this into a 2d matrix of 50x50 in Matlab?
_"... I copied the values from Matlab's command window directly …"_ That means it is a sparse matrix based on the format of ...

casi 8 años hace | 1

| aceptada

Respondida
Index exceeds array bounds help - Fibonacci Series
_"... For this reason, since at the end we only need the (N)th and (N-1)th terms, we can delete all the other ones as the loop g...

casi 8 años hace | 0

Respondida
Major speed reduction (~50x) when doing multiple matrix multiply operations in a row. Is this a (major) bug? Any ideas for a fix?
You should not store your slices as follows, since this forces each slice to be scattered in memory and does not make efficient ...

casi 8 años hace | 0

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

casi 8 años hace | 0

Respondida
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...

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 0

Respondida
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...

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 0

Respondida
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...

casi 8 años hace | 1

Respondida
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 ) % ...

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 0

| aceptada

Respondida
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(...

casi 8 años hace | 1

| aceptada

Respondida
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...

casi 8 años hace | 0

| aceptada

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

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 2

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

casi 8 años hace | 0

Respondida
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...

casi 8 años hace | 1

| aceptada

Respondida
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 %****% ...

casi 8 años hace | 0

Respondida
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 ...

casi 8 años hace | 0

| aceptada

Respondida
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);

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 1

| aceptada

Respondida
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...

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 0

Respondida
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...

casi 8 años hace | 3

Respondida
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...

casi 8 años hace | 0

| aceptada

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

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 0

| aceptada

Respondida
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...

casi 8 años hace | 4

Respondida
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., ...

casi 8 años hace | 0

| aceptada

Cargar más