Answered
trying to plot x(n) = 3cos((2*pi*3*n)/25)
E.g., n = 0:0.01:10; x = 3*cos((2*pi*3*n)/25); plot(n,x) grid on xlabel('n') ylabel('x') title('x = 3*cos...

9 years ago | 0

| accepted

Answered
Multidimensional matrix multiplication with mex
Your basic problem is a misunderstanding of how pointers work in C. Take your z variable for instance: double *z; ...

9 years ago | 3

| accepted

Answered
How to VECTORIZE this code and then convert it into a GPU code ?
Try this: x = I(:,:,2)<120 | I(:,:,1)>155 | I(:,:,3)>160; gsc = 0.2989*I(:,:,1) + 0.5870*I(:,:,2) + 0.1140*I(:,:,3); ...

9 years ago | 0

| accepted

Answered
Need help with homework
You could use a "switch" statement along with the "upper" function to handle case. E.g., an outline: switch upper(order) ...

9 years ago | 1

Answered
How do I search through a tall array element by element?
tall arrays are not "in memory". As such, they cannot be used for controlling "if" and "while" statements since their values (a...

9 years ago | 0

Answered
Could anyone give an idea to write code to solve below problem
You could create a function file and put your loop code inside that file which takes a guess as an input (for Tc(1)) and returns...

9 years ago | 0

| accepted

Answered
2nd Order ODE with RK4 hard code (w/o) built-in Matlab fuctions
You've got your step sizing messed up a bit. Suggest the following changes: % h = 1/n; %time grid % t = linspace(0,10,r...

9 years ago | 0

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

Load more