Answered
Why when comparing the class of a variable, the logical array output size differs?
Use this instead isequal(class(a),'double') or strcmp(class(a),'double') What you are doing with class(a)=='doub...

9 years ago | 1

Answered
I am supposed to write a function that takes three inputs: 1) a Coeff matrix A(nxn square mtx), right side vector b, and approximate soln' vector Xo. The function is then supposed to compute the residual vector r.
To my reading of the assignment, you are making this task more involved than it really is. The assignment states you are given ...

9 years ago | 0

| accepted

Answered
How is this simple code read?
It is the 2nd & 3rd rows and the 2nd & 3rd columns of the matrix mat. The syntax is simply extracting a sub-matrix of the origi...

9 years ago | 1

| accepted

Answered
loop problem with time delay
Hint: You could use tic and toc for this. Start your code with a tic statement. Then you can examine the toc result in a loop...

9 years ago | 0

| accepted

Answered
Loop over randn of vectors
One way, where the 3rd and 4th dimensions of the result are the 20x100 matrix of values for each original vector element. e...

9 years ago | 0

| accepted

Answered
Need help coding a grading system to a data set.
The averages you calculate are in a column vector called Student_Average, but your subsequent code does not even use that variab...

9 years ago | 0

Answered
Average of specific columns from cells in cell array
result = cellfun(@(x)mean(x(:,1)),alldata(4:84));

9 years ago | 1

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

9 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,:);

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

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

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

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

9 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>

9 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); ...

9 years ago | 4

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

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

9 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

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

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

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

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

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

9 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):-...

9 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(...

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

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

9 years ago | 0

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

9 years ago | 0

| accepted

Load more