Answered
Plotting suddenly not coming up
This is just a guess, but perhaps you are running a script which populates the current workspace with variables, and those varia...

9 years ago | 0

Answered
Some problem about ceil()
Yeah ... floating point arithmetic bites again: >> num2strexact(215.08/0.152) ans = 1.4150000000000002273736754432320...

9 years ago | 1

| accepted

Answered
Reading binary file with fread and typecast
try val2 = swapbytes(typecast(uint8(val1),'int32'));

9 years ago | 0

| accepted

Answered
How to replace values in specific lines and on determined conditions
Something like this? v = m(10276:128597,10); v( v > 11 & v < 33 ) = 1; v( v > 34 & v < 56 ) = 5; : m(10276:...

9 years ago | 1

| accepted

Answered
How to reshape/transform matrices with 3D data?
[y,x] = ndgrid(Y,X); x = x(:); y = y(:); z = reshape(Z',[],1);

9 years ago | 0

| accepted

Answered
I am trying to use a script to run simpsons rule to numerically integrate a function, it keeps giving me an error.
A script is an m-file that has MATLAB statements in it only, *without* a function statement. E.g., File myfun1.m: x = ...

9 years ago | 0

Answered
Solving for theta at different time steps
E.g., >> t = 0; >> f = @(theta) 47.9618*theta + 15.9809*sin(2*theta) - 20.780136*t; >> fzero(f,0) ans = 0 ...

9 years ago | 1

| accepted

Answered
Mex programming for a beginner
For the mex routine approach, assuming you can link with the library properly per Philip's comments, I have the following commen...

9 years ago | 1

| accepted

Answered
Generating position and velocities at different points on an ellipse
For the elliptical equivalent to uniform circular motion, I suppose you could have three choices. 1) Pick uniform angular mot...

9 years ago | 2

| accepted

Answered
What's the difference between the two pointer operators in the code gen?
I don't know _why_ the Coder will produce one form vs the other form, but by definition in the C language they mean exactly the ...

9 years ago | 0

| accepted

Answered
Writing mat file from C++ using API, empty matrix
Some problems: 1) data2 doesn't point to any of your double data ... it points to pointer_to_double values. So using memcpy ...

9 years ago | 0

| accepted

Answered
Matlab crashes when running MEX Files with large array dimensions
There are several issues: 1) You don't prototype your test function. The compiler encounters this line: test(inMatr...

9 years ago | 0

| accepted

Answered
Largest value near a 0
If I understand the assignment correctly, maybe you can use this as an outline: y = -inf; for i = 1:length(x) % W...

9 years ago | 2

| accepted

Answered
How to "squeeze" / transfer variables from a row vector into a NxN matrix?
Since MATLAB stores 2D matrix values in column order, a simple reshape will do the job: B = reshape(A,3,7); If you wante...

9 years ago | 1

| accepted

Answered
complex numbers multiplication in double precision
_"... Mind that the phases are of the order of magnitude of 10^10 radians. ..."_ When you have angles that large, I have to s...

9 years ago | 0

Answered
How to project given vectors in matlab
E.g., see this link https://en.wikipedia.org/wiki/Vector_projection u = v2/norm(v2); result = dot(v1,u)*u;

9 years ago | 0

Answered
Generate random permutation matrix
Another way: A = eye(n); A = A(randperm(n),:);

9 years ago | 4

Answered
Vector must be same lengths - please help me
I am not exactly sure how you want things plotted, but maybe this? %plot(omega, x(:,2)); plot(t,x(:,2)); hold on; grid o...

9 years ago | 0

Answered
How to Solve RESHAPE Function Error
Either: 1) The total number of elements of plmprofile1 is different between the reshape(plmprofile1,90,180) call and the resh...

9 years ago | 0

Answered
Matrix calculation + loop
Maybe this is what you want: B0 = whatever V = whatever sigma_sum = V; M = eye(4); % <-- I am guessing that you r...

9 years ago | 0

Answered
Is this a bug??
We really need to know the data types and values involved. E.g., with int8 >> a = int8([0 0]) a = 0 0 >> b ...

9 years ago | 1

Answered
how can we find the intersection point of two polynomial equations?
Subtract them and then use the roots function on the result.

9 years ago | 1

Answered
How to create a loop function within the same array?
A vectorized version (assuming I understand your dimensions correctly): diffI = [1;diff(ID(:,1))]; diffE = [0;diff(E(:,1...

9 years ago | 0

Answered
Function of ODE can not be executed well.
Make sure the derivative function returns a column vector. E.g., function dy = myODE(~,y) dy = zeros(2,1); % <-- column...

9 years ago | 0

Answered
Finding maximum value of a column in a matrix
[~,x] = max(A(:,1)); B = A(x,:);

9 years ago | 0

| accepted

Answered
Why does the following error come up for this short piece of code?
What is n? A vector? Maybe you need: H = hilb(n(i));

9 years ago | 0

| accepted

Answered
Meaning of unit vector
A unit vector is any vector v such that norm(v) = 1. For your case of order n=6, you want a 6 element vector v with norm(v) = 1...

9 years ago | 5

| accepted

Answered
Kalman filter for beginners
You need to have a good dynamics model of the system you are trying to estimate in order for a Kalman filter to make sense for t...

9 years ago | 1

Answered
How can I write "enter" or "carriage return" to a serial object?
A carriage return is ASCII code 13. Can you simply send a char(13), or perhaps an int8(13), to the serial connection?

9 years ago | 0

Load more