Answered
??? Error using ==> mtimes Inner matrix dimensions must agree. Error in ==> Untitled2 at 16 l0=[(x-15)*(x-25)*(x-35)*(x-45)]/240000;
Change the matrix operator * to element-wise operator .* E.g., x=(0:1:40); l0 = ((x-15).*(x-25).*(x-35).*(x-45))/240...

10 years ago | 0

Answered
Newton method calculations using loops??stuck!!
You are close. You need to get the result of your NewtonMethod call into the variable rn so you can do the comparison. You also ...

10 years ago | 0

Answered
How do I get values of for loop into a vector?
Is there some reason you want or need to use a loop for this? E.g., using vectorized code your inner loop can be reduced to this...

10 years ago | 0

Answered
Use BLAS library in C Mex-File
You need to use the correct integer types for BLAS/LAPACK calls. E.g., mwSignedIndex one = 1; // <-- Or ptrdiff_t one ...

10 years ago | 1

| accepted

Answered
How do I use ode45 properly? (Syntax related)
The first argument to ode45 is supposed to be your derivative function. You are attempting to pass in a matrix in this spot (and...

10 years ago | 0

Answered
How to use cgs with your own matrix-vector multiplication?
If a,c,d are pre-existing constant terms, you could use an anonymous function. E.g., afun2 = @(b)(afun(a,b,c,d)) then ...

10 years ago | 0

| accepted

Answered
(x" + sin(x) = 0). Use MATLAB’s ode45 solver to generate a numerical solution of this system over the.i nee the function w = f(t,x), x =z(1) and the code for w in order to solve the IVP
Some hints: Turn this single 2nd order equation into two 1st order equations. E.g., define a 2-element vector y (or some othe...

10 years ago | 1

Answered
How does matlab provide precise Taylor expansions for some truncation order?
Not sure what you are really asking here. There is a taylor function in the Symbolic Toolbox that does such expansions for whate...

10 years ago | 0

Answered
Need Help making a nxn symmetric matrix
Making a guess at what you really want, you could build it in pieces, e.g., n = size of matrix; A = zeros(n); A(1:n+1...

10 years ago | 0

| accepted

Answered
I am trying to create an array that displays the values 1-25 and puts the correct calculation next to it
You could move the fprintf *inside* the loop, just before the "end" statement. E.g., fprintf('%2d %d\n',i,A(i)); %%% Print...

10 years ago | 0

Answered
How can I find the index and value of the smallest element within a range of values in a vector
You could add code to map the index back into the original vector. E.g., rangeTestVals = testVals>loVal & testVal<hiVal; ...

10 years ago | 0

Answered
How to define function to work on any double array
The error message you are getting is typical when MATLAB can't *find* the function. Check your path to ensure that the file test...

10 years ago | 0

| accepted

Answered
how to define if or for for the following question
xy = [x;y]; minxy = min(xy); maxxy = max(xy); g = x - y < 0; d = x; d(g) = maxxy(g); d(~g) = minxy(~g);

10 years ago | 0

| accepted

Answered
Function with Multiple Outputs
You can call it like this: [~,n] = fun(x);

10 years ago | 0

| accepted

Answered
Integrating experimental acceleration data to get velocity and position
Can't you just do an accumulated sum on the acceleration (with appropriate scaling) to get velocity, and then an accumulated sum...

10 years ago | 0

Answered
Error: Subscript indices must either be real positive integers or logicals.
E.g., in these lines: x(1i)=1.236; y(1i)=0.0734; 1i is the imaginary number sqrt(-1) ... it is not a valid value to u...

10 years ago | 0

Answered
Unexpected MATLAB expression in MATLAB
This line uses the _function_ keyword, which means you are starting a function definition: function [F, V, N] = read_stl_fi...

10 years ago | 1

| accepted

Answered
Is there any way we start with all ones vector of length 10 and need to increment it in steps till we have a vector of length 10 with each element equal to 30
Start with: v = [1 1 1 1 1 1 1 1 1 1 ]; Then for each increment do this: v = v + 1;

10 years ago | 0

Answered
"Insufficient number of outputs from right hand side of equal sign to satisfy assignment."
You likely have inadvertently created a variable named "min" in your code, which is shadowing the function min. Go find that var...

10 years ago | 25

| accepted

Answered
Get the row index of matrix where the first 3 columns are equal in two matrix
Assuming the match is always in the first three columns (caution, untested): k = ismember(A(:,1:3),B,'rows'); D = A(k,:)...

10 years ago | 0

| accepted

Answered
find rows of two matricies (of different sizes) based on matching element of one column
Caution, untested: k = ismember(A(:,4),B(:,4)); C = A(k,:);

10 years ago | 0

Answered
How do I sort the rows in one array based on the row order of another array?
Try this (Caution, untested since I am not on a machine with MATLAB at the moment): [~,Locb] = ismember(New_C,C,'rows'); ...

10 years ago | 0

| accepted

Answered
Where am i going wrong in this "for loop" script associated with the question below? See the script below the question:
You are missing the "for" key word: for x= 0:5:100

10 years ago | 0

| accepted

Answered
mexCallMATLAB Memory Leak / mxDestroyArray / C++ Crashing
Some comments: 1) The signature for mxCreateNumericArray shows the dims argument as being mwSize, not mwSignedIndex. So this ...

10 years ago | 2

| accepted

Answered
uses of 'zeros' and 'ones' function ?
A couple of examples. zeros is often used to allocate a variable to a known size, then downstream code will fill in the indiv...

10 years ago | 1

| accepted

Answered
How can I make called my function stay in the memory so it can be efficiently run in loop?
The first time you call a function it is parsed and put into memory. It will subsequently stay in memory unless you do somethin...

10 years ago | 0

Answered
Calling LAPACK in MEX files
Some observations: 1) You are using mwSize for the type of integer to use for the LAPACK arguments. Don't do this since this...

10 years ago | 1

| accepted

Answered
How do I convert from a while loop to a for loop?
for i=0:11:109 fprintf('i = %d\n',i) end

10 years ago | 2

| accepted

Answered
How can use "is not equal to" command in matlab? and how terminate or cancel if else??
E.g., if( length(a) ~= length(b) || length(c) ~= length(a) ) % terminate end For the terminate statement, you ...

10 years ago | 0

| accepted

Answered
"depth" of mexMakeArrayPersistent ?
Repeated from this link: http://www.mathworks.com/matlabcentral/newsreader/view_thread/343079 Persistence of mxArray varia...

10 years ago | 1

| accepted

Load more