Answered
How should I mex a fortran code(main function) that calls other fortran codes(sub function) that in different files
The modules need to be compiled first so that the interface .mod files are available for the downstream compiling. This can be ...

9 years ago | 0

Answered
Operands to the || and && operators must be convertible to logical scalar values. Im not sure what i did wrong. Any help would be greatly appreciated.
The way you have F defined, it will return a vector since it uses x and x is a vector. This is causing the error. You need to ...

9 years ago | 0

Answered
please, can anyone tell me the solution of this differential equation in matlab "D2y + 4Dy + 3*y = exp^(2*x)"
One particular solution found by inspection, assuming I understand your equation, is: y = exp(2*x)/15 And the homogeneous so...

9 years ago | 0

Answered
I am trying to create a mex file for FORTRAN90 code. I get an error because of '&' and long sentences in the FORTRAN90 code
This is usually caused by TMW including a compiler option in the mex option files to force fixed field source even if the file h...

9 years ago | 0

| accepted

Answered
[Homework Help] Stuck with result. && use not working as intended (easy?)
Here is what I get, after changing your != operator to a ~= operator: >> X=[1, 2, 3, 4] X = 1 2 3 4 ...

9 years ago | 1

| accepted

Answered
How to create a weighted average for the following data?
One way: result = sum(bsxfun(@times,reshape([Avg.population],1,1,[]),reshape([Avg.average],15,15,[])),3)/sum([Avg.populatio...

9 years ago | 0

Answered
Matrix dimensions must agree - 3 chances loop
Your fundamental problem is how you are doing string compares. Do not use the == operator since that is an element-wise operato...

9 years ago | 0

| accepted

Answered
Retreiving property value of each object in array
Maybe use a cell array instead? listOfNames = {handles.library.name};

9 years ago | 1

| accepted

Answered
How to modify a struct and create a new struct out of it?
One way, but note there will be loops in the background: X = [A.X]; Y = [A.Y]; Z = [A.Z]; [theta,phi,r] = cart2sph...

9 years ago | 0

Answered
How to transform an array from n x m into nm x 1?
B = A.'; B = B(:); or B = reshape(A.',[],1); In both cases, the transpose is necessary to get the elements of A ...

9 years ago | 0

| accepted

Answered
I have a vector with M elements. And I want to divide it into parts, with "n" elements each. How do I do that?
I guess the obvious answer, if n is evenly divisible into M, is simply to reshape it v = your M-element vector parts = r...

9 years ago | 0

Answered
how to create a 1x3 cell array to hold multiple individual arrays
my_cell_array = {a,b,c}; Or if you are simply asking how to pre-allocate the cell array in advance: my_cell_array = ce...

9 years ago | 1

| accepted

Answered
Help passing column vector of doubles to function to get letter grade for all grades
Call your function in a loop for each element of n, or put code inside your function to loop over all the elements of n. For th...

9 years ago | 1

| accepted

Answered
I'm attempting to write a function that calculates the value of sine using a taylor series to within a tolerance of 10^-6. I think my loop is set up correctly but i'm not sure the series equation is correct as my function never stops running.
You are close, but have a few errors. The errors are: 1) The exponent on x should be 2*n+1, but you have 2*(n+1), which isn'...

9 years ago | 1

| accepted

Answered
Write matrix with Matlab and Read with C?
Use fopen, fwrite, fread. EXAMPLE: m-code: xbinary_create.m x = 1:5; fid = fopen('xbinary.bin','w'); fwrite(fi...

9 years ago | 0

Answered
Matrix Multiplication Using For Loop
The error message is pretty clear. You are attempting to build the x variable out of four other variables named x1, x2, x3, x4....

9 years ago | 1

Answered
Struct contents reference from a non-struct array object.
Issue the following command: dbstop if error Then run your code. When you encounter the error, the code will pause. Exam...

9 years ago | 0

Answered
what is meant by 'Cell contents reference from a non-cell array object'.
It means you used the curly braces { } on a variable that was not a cell array. E.g. >> x = {5} % <-- a 1x1 cell array, t...

9 years ago | 1

Answered
Unexpected matlab expression error
For function definitions, you need to have variable names for the input argument list, not explicit values. E.g., this line ...

9 years ago | 0

Answered
Invalid MEX-file 'D:\sky_detector\toolbox\bin\gco_matlab.mexw64': The specified procedure could not be found..
It is not unusual for mex routines to be dependent on the MATLAB version. I.e., mex routines compiled under one version of MATL...

9 years ago | 0

Answered
How can I solve a matrix differential equation within MATLAB?
E.g., if you are using ode45, then simply reshape F and the initial Fo into column vectors. Inside the derivative routine, resh...

9 years ago | 12

| accepted

Answered
While loop - display the last value while statement is still true
You could just use another variable. E.g., y x=0 p=1-poisscdf(1,x); while p<=0.1 y = x; % <-- save current v...

9 years ago | 1

| accepted

Answered
How do I delete columns from a matrix based on an array
A(:,ismember(A(1,:),B)) = [];

9 years ago | 2

| accepted

Answered
How to access Matlab string() data in MEX/C?
I don't have a recent enough version of MATLAB & C compiler to check this, but I suspect that the string class is an OOP classde...

9 years ago | 1

Answered
Only first for loop is being executed. What im i doing wrong?
It is a bit unclear why you are attempting to use for-loops here. From the looks of things, it appears that maybe you need to u...

9 years ago | 1

| accepted

Answered
output from an if statment
These statements: zn=cell(1,fx); zn(l)=zs(1); The first statement above wipes out any previous values/cells...

9 years ago | 0

Answered
Putting different outputs in one vector matrix
Is this what you want? x = 1:9; % a vector with elements 1, 2, ..., 9 y = sin(x) - cos(x); % the vector result at each...

9 years ago | 0

| accepted

Answered
Fundamental question: How does MATLAB calculate the sine function?
MATLAB doesn't publish all of their function algorithms, but I would guess it would be range reduction followed by a rational fu...

9 years ago | 0

Answered
Select from 2D Array by 2 criteria - Matlab
Try this: y = your 2D matrix x = y(:,2) > 0.9 & y(:,2) <= 1.2; z = y(x,:); [~,k] = max(z); result = z(k,:);

9 years ago | 1

| accepted

Answered
Undefined Variable; Q7day, help! Thank you
If you never get inside the for loop, Q7day will not get defined and that last line will error. Run your code in the debugger a...

9 years ago | 0

Load more