Answered
Write a function named sindeg that takes a matrix input deg and returns a matrix M that computes the sine of the elements in the input matrix. A second output contains a scalar that is the average of the first.
Assuming your real issue is with 2D matrices (or even 3D arrays etc), and that you need to provide a scalar for that second outp...

8 years ago | 0

| accepted

Answered
Using the unique function to eliminate rows containing the same integers in a different order.
[~,x] = unique(sort(D,2),'rows','first'); result = D(x,:);

8 years ago | 1

| accepted

Answered
How to I reverse the contents of this array?
For that last index, don't use end-3 since that will only work for a 4 element array. Instead, have that last index be simply 1...

8 years ago | 1

| accepted

Answered
Dot Product function errors
You have inadvertently created a variable named "dot" that is shadowing the MATLAB function named "dot". Clear that variable na...

8 years ago | 1

Answered
For loop comand use
The general outline of your for loop would be: total = 0; for k=start_value:increment:end_value % <-- you fill in the s...

8 years ago | 0

| accepted

Answered
Error while using Surface Intersection function in a loop "Subscript indices must either be real positive integers or logicals"
Often this is the result of having a variable with the same name as a MATLAB function you are using, so the variable is shadowin...

8 years ago | 0

Answered
How to call a fortran 90 subroutine for Windows?
See this link: <https://www.mathworks.com/support/sysreq/previous_releases.html>

8 years ago | 0

| accepted

Answered
Conversion to double from function_handle is not possible.
You can't store function handles inside a double variable. You must use a cell array instead. E.g., >> f = zeros(2,1); ...

8 years ago | 4

Answered
How to write multiple rows in a multiple column way without changing the order
result = reshape(A.',1,numel(A));

8 years ago | 0

| accepted

Answered
How to call data from a structure?
How do you want to use it? If you are talking about the results of your last Question, it is a "cell array" and not a "structur...

8 years ago | 0

| accepted

Answered
Finding the line of best fit for a set amount of data points
Extract the data you want to fit and then you could use polyfit. doc polyfit

8 years ago | 0

Answered
How can I make smaller matrices (size unknown) from a large matrix?
M = your matrix; result = cellfun(@(x)M(M(:,8)==x,:),num2cell(1:36),'uni',false);

8 years ago | 1

| accepted

Answered
how would I ask a user to input a vector without loops?
Prompt the user to enclose their numbers in square brackets.

8 years ago | 0

| accepted

Answered
How can I use a for loop counter in an anonymous function?
I don't think you have a real problem, other than in appearance. At the creation of the function handle, a snapshot of the vari...

8 years ago | 1

| accepted

Answered
Cell contents assignment to a non-cell array object.
This line trainingFeatures=zeros(etc); means that trainingFeatures is a double class matrix. But this line: trai...

8 years ago | 1

Answered
2x1 structure array to structure array
You explicitly add that 2nd struct element with this line: schedule=[schedule;struct(field1,value1,field2,value2,field3,val...

8 years ago | 1

| accepted

Answered
Index out of bounds in a for loop
Run your loop backwards so that the reduced indexing is not a problem (not very efficient btw): for aa = length(Ytotal):-...

8 years ago | 1

Answered
Limit values based on one column?
Something like this? u = unique(B(:,1)); for k=1:numel(u) d = B(B(:,1)==u(k),:); figure; scatter(d(:,2),d(...

8 years ago | 0

| accepted

Answered
Solved for a variable dependent on z in file 1, want to call this variable (as it changes in z) in an ode45 solver in file 2. How do I do this?
The variable z that is passed into gasbal from ode45 could be any fractional number, not necessarily an integer. Looks like you...

8 years ago | 1

| accepted

Answered
What's the best way to pass structures into/out of C++ functions?
_"... decomposes the strut to its component inputs, then reconstructs it on the back end, which isn't ideal either ..."_ If y...

8 years ago | 0

Answered
Removing rows from arrays in cells using indexing
result = cellfun(@(x,y)x(~y,:),A,idx,'uni',false);

8 years ago | 0

| accepted

Answered
why i got this error?
Make it a column vector as requested: dFdx=[F(2) ; -K1*P+F(1)*Lamda^2];

8 years ago | 0

| accepted

Answered
ode45 to Solve System of ODEs
Set up the state as a 2-element vector y. Then define the following: y(1) = coordinate location y(2) = velocity Writ...

8 years ago | 0

Answered
For stability I require that ( 2 * (1+e^(-T)) / (1-e^(-T)) ) - K > 0. How can I plot this?
Not sure what values of T you are interested in, but here is how you can plot it: K = 2; % <-- or some other value f = ...

8 years ago | 0

Answered
Index error when calculating mean of a column
You have inadvertently created a variable called "mean" in your workspace that is shadowing the MATLAB function "mean". Clear t...

8 years ago | 1

| accepted

Answered
Hello question to iterate over elements of a column
Break out of the loop when you find that first non-zero value: if zRPM(i) ~= 0 boutstart = zRPM(i); sta...

8 years ago | 0

| accepted

Answered
Why is my line not showing up on my plot?
The loop does not work because x is not a vector after the loop. You have used x as the index variable, which is a scalar. Cha...

8 years ago | 0

| accepted

Answered
Using kronecker product and elementwise multiplication
yy = repmat(y,size(der,1),1); result = bsxfun(@times,OMEGA,yy(:)); or in later versions of MATLAB result = OMEGA .*...

8 years ago | 0

| accepted

Load more