Answered
Matlab incorrectly reading a binary file
Please show the Fortran code that was used to write the file, and also the Fortran code that correctly reads the file. Depending...

8 years ago | 0

Answered
I'm not sure how to set the stop criterion in the bisecting method
Inside the loop you can use this: if( abs(a-b) <= epsilon ) break; end Where epsilon is a value you set prior ...

8 years ago | 0

| accepted

Answered
Removing matrix rows in while-loop
In general, you should not remove rows in a loop. Instead, keep track of which rows you want to delete and then delete them all ...

8 years ago | 1

Answered
Hi, can you help me!!! I 've got a problem when i went to calculate this matrix:
You need to tell MATLAB how many 0's are being concatenated in the upper right corner. E.g., A = [Aa zeros(size(Aa,1),size...

8 years ago | 0

Answered
Finding the area under a polynomial equation in MATLAB
Just integrate the polynomial and evaluate at the endpoints. E.g., IB = polyint(B); area_under_poly = polyval(IB,X(end))...

8 years ago | 1

Answered
Eliminate zeros from array
AT = reshape(A',1,[]); BT = reshape(B',1,[]); B = BT(AT~=0); A = AT(AT~=0);

8 years ago | 0

Answered
when I add two floating point numbers the result is not correct above 262144
The amount you are adding, 0.01, is less than the eps of the number you are using. E.g., >> a = single(262144.000) a = ...

8 years ago | 0

| accepted

Answered
mxUnshareArray doesn't seem to work
I haven't forgotten this Question, but I don't know enough to completely answer it yet. That being said, I will give it a start ...

8 years ago | 0

Answered
How can I speed up the multiplication of matrices?
Q1: Why do you pre-allocate a bunch of 6000x6000 full matrices for d11, d12, and d22 only to downstream use sparse( ) on them an...

8 years ago | 0

Answered
How do i calculate the inverse of a non-square matrix?
Typically one would use backslash \ or perhaps pinv( ) for this. What are you using this for? I.e., what is the problem you are ...

8 years ago | 0

| accepted

Answered
Create a pseudo-random array with a set probability of similarity to an existing random array
E.g., n = numel(array1); % total number of elements n2 = floor(n/2); % half of them x = randperm(n,n2); % random posi...

8 years ago | 0

Answered
How to make sure that ratios of very large numbers(e^1000+1)/(e^1000-1) is not given as NaN?
You can use an alternate formula for the large values: T = (1 + 1./exp(x)) ./ (1 - 1./exp(x)) Note that once x gets larg...

8 years ago | 1

| accepted

Answered
How can I write a Matrix with different elements by typing in a single command?
By putting it all on one line: [0 0 0 0 0; 0 0 1 10 20; 0 0 2 8 26; 0 0 3 6 32] But why do you need it on one line? The...

8 years ago | 0

Answered
Cant execute my nested sub-functions
You need to put code in your primary function to call the subfunctions to create the tables. E.g., function []=temperature_...

8 years ago | 0

| accepted

Answered
Operations between matrix, different calculation according to conditions.
Cs(:,1) = (fs-.85*21*(d<c)).*As/1000;

8 years ago | 2

Answered
Problem to solve exponential equation
Why not solve it directly: x = 1./log(b) What's the point of using vpasolve for this?

8 years ago | 0

Answered
No performance improvement with preallocating for object arrays
Pre-allocation of variables means different things depending on the variable class. *(1) Numeric, char, and logical classes:...

8 years ago | 1

Answered
Shuffling non-zero elements of each column in a matrix
You're probably going to need a loop for this since the number of non-zero elements in a column is not constant across all the c...

8 years ago | 1

| accepted

Answered
Solution for getting only one variable equal to 1 while other two variables 0.
E.g., if I understand your request: n = 3; % number of elements to use for k=1:n x = zeros(1,n); x(k) = 1;...

8 years ago | 0

| accepted

Answered
How to select some columns from a no of columns uniformly in MATLAB ?
M = original matrix result = M(:,randperm(size(M,2),200)); If you need the columns to be in the same order as the origin...

8 years ago | 0

Answered
How to run predefined user inputs for a script inside a script?
Is this what you want? %script2 if( ~exist('X1','var') ) X1 = input('enter a value for X1: ') end if( ~exis...

8 years ago | 0

Answered
How do I code matlab to recheck while loops before continuing?
Maybe something like this logic is what you need, although you don't specify a way to get exe set to 0 so you would have to add ...

8 years ago | 0

Answered
Having trouble getting function to return two values
Your code has a path where nothing gets assigned to the output variables. Also, even for the path that does assign the output va...

8 years ago | 0

Answered
How to use Euler method with IVP with function of x and y?
3x is not a valid MATLAB expression. You need to have the multiplication operator between the 3 and the x. Also, you need to use...

8 years ago | 1

| accepted

Answered
How to count the number of consecutive repetitions of an array?
E.g., [r,s] = runlength(A,numel(A)); result = r(logical(s)); You can find runlength on the FEX: <https://www.mathw...

8 years ago | 1

| accepted

Answered
Physics problem help!
So, I will give you a start for an Euler scheme. You have two states to keep track of, the position and the velocity. Define two...

8 years ago | 0

Answered
code is showing error with some inputs
Why are you using v(1:1) as an index into v? Did you mean this instead? w = v(end:-1:1); Also, it is not clear from you...

8 years ago | 0

| accepted

Answered
Confusion in using polyfit and polyval to predict data
Because that is the "time unit" used for your polyfit calls earlier in the code: nz_years_adjust=(nz_years-1900)/50; I.e...

8 years ago | 1

| accepted

Load more