Answered
How to normalize data between 0 and -1.4?
E.g., using simple linear scaling based on the range of the current data: data = your matrix actual_min = min(data(:)); ...

9 years ago | 0

Answered
create a matrix from a for loop and store it or allot it one after the other from a for loop
You could save each piece in a cell array: Kb = cell(4,4); : Kb{i,j} = [ 0 0 0 : Then a...

9 years ago | 0

Answered
how to loop over the structure fields and get the type of data ?!
You could loop over the fieldnames, e.g. fn = fieldnames(mystruct); for k=1:numel(fn) if( isnumeric(mystruct.(fn{...

9 years ago | 47

| accepted

Answered
Logical indexing of matrix doesn't output matrix of the correct dimensions
Is this what you want? I just added the colon : to select all of the columns. window = userData(windowLogical,:); (In g...

9 years ago | 0

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 1

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 2

| accepted

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

9 years ago | 0

Answered
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; ...

9 years ago | 0

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 1

| accepted

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

9 years ago | 0

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 3

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

9 years ago | 0

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

9 years ago | 1

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 0

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

9 years ago | 0

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

9 years ago | 0

Answered
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]; ...

9 years ago | 0

Load more