Respondida
Index Exceeds Matrix on Runge Kutta Method
I took your code and made some changes to get it to run and produce a plot. Changes are noted in comments: % Define Param...

casi 10 años hace | 0

| aceptada

Respondida
given f(x) and h, how to I calculate f(x+h)
E.g., using an anonymous function: >> f = @(x) x^4 f = @(x)x^4 >> h = 0.1 h = 0.1000 >> x = 5 ...

casi 10 años hace | 0

Respondida
"Index exceeds matrix dimensions" error in For Loop
You've got these two lines that define t differently: t = -T/7:0.001:T/7; syms t What is your actual intent for t? T...

casi 10 años hace | 0

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

casi 10 años hace | 0

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 2

| aceptada

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 0

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

casi 10 años hace | 3

| aceptada

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

casi 10 años hace | 0

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

casi 10 años hace | 0

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 3

| aceptada

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

casi 10 años hace | 2

| aceptada

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 0

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 1

| aceptada

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 0

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

casi 10 años hace | 0

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

casi 10 años hace | 0

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

casi 10 años hace | 1

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

casi 10 años hace | 1

| aceptada

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

casi 10 años hace | 0

| aceptada

Respondida
When I try to run the following line of code, I get the error message "Not enough input arguments. Error in Un2 (line 6) if (R<=0)||(H<=0)" Although I understand the content of the error message, I cannot determine what is wrong with my syntax.
It means that R and/or H were not passed in as arguments to the function. Did you just push the green triangle "Run" button to ...

casi 10 años hace | 1

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

casi 10 años hace | 0

| aceptada

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

casi 10 años hace | 0

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

casi 10 años hace | 0

| aceptada

Cargar más