Answered
How do I change the format of an output number?
fprintf('Which comes to a total per month pre-pension of: %5.2f \n',CashPerMonth);

9 years ago | 0

Answered
How can I fetch the column numbers in a vector?
Just use find: columns = find(v==2);

9 years ago | 0

| accepted

Answered
How to call a column in a vector
Get the 2nd output argument returned from the min function: [value,column] = min(v);

9 years ago | 0

| accepted

Answered
MATLAB encountered an internal error and needs to close -MEX file
Some comments: ---------------------------------------------------------------------------------------- IMPLICIT R...

9 years ago | 2

| accepted

Answered
Can anyone help me with this question using MATLAB? I'm not sure which function to use.
Assuming the data is normally distributed, you could use the normcdf() function. You have to know how to calculate the mean and...

9 years ago | 0

| accepted

Answered
How to remove array elements that are elements of a different array
Assuming relations{k} is some arbitrarily sized array and max_commons is some arbitrarily sized vector: relations{k} = rela...

9 years ago | 0

Answered
Error using ^, inputs must be scalar and square matrix
Use element-wise power _and_ element-wise divide: func=@(x) (1./(1+x.^2))

9 years ago | 3

| accepted

Answered
a matlab code of getting a value uniformly at random from a the set {-1,1}
Yet another way (although Matthew's Answer is faster so I voted for it): N = number of values R = 2*randi(2,N,1) - 3;

9 years ago | 0

Answered
How to change the value of a variable each time a loop runs?
Do you want each result in a different cell? E.g., alpha = [0.271, 0.579, 1.2, 3.27, 11, 36.2, 91.5, 154]; D = cell(num...

9 years ago | 0

Answered
Parameter that depends on a State Variable
In this line: [tt,xa]=ode45(myodefun,[0:0.01:7],x0); The 1st argument to ode45 is myodefun, which is a _call_ to the fun...

9 years ago | 0

| accepted

Answered
Why is floor(2.00000000) giving me a result of 1?
If the number is displaying as 2.0000... on the screen, it isn't exactly 2 but it is close to 2. If a number is exactly 2 it wil...

9 years ago | 3

| accepted

Answered
Matlab 2016b Matrix Dimensions for addition and subtraction?
Yes, this is a new feature and is intentional. See this link under Implicit Expansion: http://www.mathworks.com/help/matlab/r...

9 years ago | 2

| accepted

Answered
Removing ceratin columns from matrices
If the indexes you want removed are in sorted ascending order, you could probably just reverse the order of your for-loop indexi...

9 years ago | 0

| accepted

Answered
How can ı Fix it ; In an assignment A(I) = B, the number of elements in B and I must be the same.
In this line, you are trying to assign a vector (rhs) to a single element (lhs) if N > 1. So this will generate an error: Q...

9 years ago | 0

Answered
Generate a random matrix between -5 to 25 with a Gaussian distribution. Let user to enter the size of the matrix?
doc randn Although it is not clear what you mean by the phrase _"... between -5 to 25 with a Gaussian distribution ..."_ si...

9 years ago | 0

| accepted

Answered
New to Matlab- how do I do a calculation on a variable without creating a matrix?
Input your values as numbers instead of as strings by dropping the 's' argument. Also, change your fprintf statements so that al...

9 years ago | 1

| accepted

Answered
Why doesn't A*P produce the right answer?
MATLAB is producing the correct answer. Your understanding of matrix multiplication is not correct. The operation that gives the...

9 years ago | 0

| accepted

Answered
How do I get the script to loop to the beginning?
Thanks for posting your work so far. Some hints: _"The script should then make a call to the f(x) Polygon repeatedly to comp...

9 years ago | 0

Answered
In mex file, I can't overwrite scalar value through the pointer in matlab2016a, although I can overwrite the scalar value through the pointer in matlab2013a and I can also overwrite the array through the pointer in matlab2016a.
One possibility is that MATLAB is not passing "a", but a copy of "a" to the mex routine. In my experience MATLAB always has pass...

9 years ago | 0

Answered
I have an Equation with all known constants. Except one variable changes from 500 to 1000 in an increment of 100 (so it can be a vector) how can I solve this equation for each value from 500 to 1000?
Use the element-wise version of the operators which begins with a period. E.g., m = whatever RH = whatever H = 500:10...

9 years ago | 0

Answered
How to vectorize multiplication of matrix with 3D tensor?
You are probably thinking of "pagefun" which is for gpuArrays. Here are some nd matrix multiply options from the FEX (some ar...

9 years ago | 1

Answered
How to compute the coset C of A w.r. to I ( where I is the union of C and A)
Is this what you want? C = I(~ismember(I,A));

9 years ago | 1

| accepted

Answered
How do I replace a maximum value with zero?
A = your matrix A(A==max(A(:))) = 0;

9 years ago | 0

| accepted

Answered
Solution to "Subscripted assignment dimension mismatch" error
Looks like you are attempting to create a series of variable names with embedded numbers. This is usually a bad idea. Hard to co...

9 years ago | 0

| accepted

Answered
Mex Function only returns zero ... and sometimes MATLAB gives system Error.
You don't show enough code for me to determine with certainty what is going on. For instance, the following are not defined anyw...

9 years ago | 0

Answered
Changing a string in a matrix to a variable with a value given in another matrix.
Well, you can do this using the eval() function, but it is generally not a good idea to do so. You are popping these variables i...

9 years ago | 0

| accepted

Answered
continue, how to skip part of a cycle
Your if-test and continue statement are inside the inner while loop, so they apply to that loop, not the for-loop. Maybe use a b...

9 years ago | 0

| accepted

Answered
Matrix Element Transfer from one matrix to another
I am not quite clear what you are asking. Is it something like this? >> A = reshape(1:100,10,10) % <-- test data A = ...

9 years ago | 1

Answered
Matlab M-File
You should review the documentation on how to write a function, since your above code is not a correctly written function. First...

10 years ago | 1

| accepted

Load more