Respondida
how do I turn the columns and rows in a random matrix?
result = flipud(fliplr(your_matrix)); or result = reshape(your_matrix(end:-1:1),size(your_matrix)); or result ...

alrededor de 9 años hace | 1

| aceptada

Respondida
Double precision in mex file
_Can the mex file reduce somehow precision of a variables?_ No. Double precision in a mex routine is the same as double preci...

alrededor de 9 años hace | 0

| aceptada

Respondida
After Mex compilation fails, Matlab crashes and doesn't open again
Lp=mxCreateNumericArray(1, &N1, mxDOUBLE_CLASS, mxREAL); : for (i=0;i<N1;i++) { : ((dou...

alrededor de 9 años hace | 0

Respondida
Hi, I'm writing a Runge Kutta function to solve a higher order differential equation and I need to get the error to around 10^-11.
You need to rewrite your derivative function as a vector function to account for the higher order derivatives. You've got a 4x1...

alrededor de 9 años hace | 1

| aceptada

Respondida
Multiply Each Matrix in Cell Array by a Different Value
result = cellfun(@times,A,num2cell(b),'uni',false); But this just moves the loops (which are part of cellfun) into the back...

alrededor de 9 años hace | 1

| aceptada

Respondida
create binary 0 and 1
subA = A(sum(A,2)==3,:); For subB it is not entirely clear to me what you want. Do you want the rows of A arranged so that...

alrededor de 9 años hace | 0

| aceptada

Respondida
sort from largest to smallest
sort(A(:,1),'descend') If you want to sort the matrix A by rows based on the first column, then e.g. flipud(sortrows(A...

alrededor de 9 años hace | 2

| aceptada

Respondida
increasing spdiags matrix at each iteration
A2 = repmat(A2,1,i); But it seems to me that you may be running into memory problems with this, since A2 is recursively usi...

alrededor de 9 años hace | 0

Respondida
Write a function called approximate_e that uses the following formula to compute e, Euler’s number: = 1 ! ∞ = 1+1+ 1 2 + 1 6 + 1 24 +⋯ Instead of going to infinity, the function stops at the smallest k for which the approximation differs from
You need to change your while loop criteria to compare your estimate with exp(1). E.g., while abs(est-exp(1)) > delta

alrededor de 9 años hace | 0

| aceptada

Respondida
how do i select a number from a set randomly
If you are just interested in the values -1 and 1, you could do something like this: Asimulac = round(rand(101,5))*2-1; ...

alrededor de 9 años hace | 0

Respondida
Problems with simulation of Earth-Moon trajectories around the Sun
I haven't looked at your derivative equations yet, but the order is definitely wrong. E.g., take the first two elements: i...

alrededor de 9 años hace | 0

| aceptada

Respondida
Reverse the value in multiple columns
x = your matrix c = a vector with column numbers to reverse x(:,c) = 6 - x(:,c); e.g., >> x = randi(5,6,6) % <-...

alrededor de 9 años hace | 0

Respondida
How to plus two nan matrix
c = a + b; c(isnan(c)) = a(isnan(c)); c(isnan(c)) = b(isnan(c));

alrededor de 9 años hace | 1

| aceptada

Respondida
How do I make a function file that can calculate the modified eulers method?
For Modified Euler's Method, you simply average the derivative at your initial point and next point, and then use that to take a...

más de 9 años hace | 0

Respondida
how to cut the matrix
x = [1 0.1 2 0.2 3 0.3 4 0.5 5 0.6 6 1.2 7 1.2 8 1.3]; >> y = x(x(:,2)<1.2,:) y = 1.0000 ...

más de 9 años hace | 0

| aceptada

Respondida
Help with creating a modified Euler method for a bungee jumping question
For Modified Euler's Method, e.g. this link: https://mat.iitm.ac.in/home/sryedida/public_html/caimna/ode/euler/ie.html Bas...

más de 9 años hace | 0

Respondida
Which standard MATLAB functions do you shadow with your own version, and why?
I have intentionally shadowed fopen, fread, fwrite, fclose before. Options that would read/write VAX binary format numbers were...

más de 9 años hace | 3

Respondida
I have 100 2D matrix .. After each matrix, I calculate the sum of elements inside it .. I want to see only the matrices with summation result under certain value (such as: 23). How can I do this?
E.g., if they were stored in a 3D array: >> m = randi(10,3,3,5) % some random data m(:,:,1) = 5 8 7 ...

más de 9 años hace | 0

Respondida
Anyone know what I am getting this error?
Use the debugger. First, type the following: dbstop if error Then run your code. When the error occurs, the program wi...

más de 9 años hace | 1

Respondida
Incorrect number of arguments into mex file
Particularly for Fortran, you should always use the exact signature that is in the doc. Sometimes that signature changes from r...

más de 9 años hace | 1

| aceptada

Respondida
What if I find an error in the documentation
Go to this link: https://www.mathworks.com/support/bugreports/ Click on the green "Report a Bug" near the top right, and g...

más de 9 años hace | 0

| aceptada

Respondida
Accessing an array that is singles which is part of a structure is really slow
Timings like this are inherently unreliable. The actual operations involved are extremely simple, so the runtimes can easily be...

más de 9 años hace | 0

Respondida
I am trying to plot within a for loop, but it is only plotting the last set of data. How would I get all three sets of data in the same graph. The code is included
Change hold off to hold on Also, I assume those labels and title were meant to be on the plot, not set as actua...

más de 9 años hace | 0

Respondida
Random path coordinates in 2D within a unit square
Any restrictions on the path? E.g., would 1000 random points suffice: mypath = rand(1000,2); % <-- each row is an (x,y) p...

más de 9 años hace | 0

Respondida
How to quary (building a new matrix based on some information)
C = B(ismember(B(:,1),A(:,1)),:); D = C(C(:,2)==1,:);

más de 9 años hace | 0

Respondida
how to assign different value for each input
Not quite sure what you really want, but here is a start: ci = [0.9 0.95 0.99 0.999]; c = [1.645 1.960 2.576 3.291]; ...

más de 9 años hace | 0

Respondida
How do I combine matrices of different dimensions which are obtained in a for loop?
Do you mean something like this? result = zeros(10,11); for k=1:10 result(k,1:k+1) = 1:k+1; % or whatever the co...

más de 9 años hace | 0

Respondida
Error is compiling mex file in MATLAB with intel compiler "Intel Visual Fortran Composer XE 2013 with Microsoft Visual Studio 2010"
For a fixed format source file, the continuation line must have the continuation character in column 6. You have several lines ...

más de 9 años hace | 0

Respondida
Further improvement of matrix inversion
_How can we further speed up this inversion if we know from the beginning that Cholesky decomposition can apply in our matrix?...

más de 9 años hace | 1

| aceptada

Respondida
Why can't Mex C/C++ Code With Xcode on Mac (MatlabR2015a)?
There are no spaces between the directive and the token. So change these lines #ifndef_DOUBLEIT_H_ #define_DOUBLEIT_H_ ...

más de 9 años hace | 0

| aceptada

Cargar más