Answered
mexGetPr error when freeing the data
These lines show that rlist and r come from the MATLAB Memory Manager: rlist=mxGetPr(prhs[8]); r=mxGetPr(prhs[9]);...

10 years ago | 0

| accepted

Answered
2d matrix to 3d matrix conversion with signals
x = your 900000x250 matrix xnew = reshape(x',250,150000,6);

10 years ago | 0

Answered
Volume of a cylinder
Seems like you have this information: V1 = pi*(r1^2)*h1 <-- this is all known V2 = 1.2 * V1 <-- this is given ...

10 years ago | 1

| accepted

Answered
Extract elements from a heap
I am assuming you have a typo in your code above and are really starting with keys in sorted _"consistent"_ order ... i.e., I as...

10 years ago | 1

| accepted

Answered
Matlab crashing when evaluating mex
Here is some sample code for you to peruse. It takes a 2D matrix input and writes the input values to the screen using various ...

10 years ago | 1

| accepted

Answered
Problem With Graph In Function
E.g., something like this to get you started T = 1:1:t+1; m = size(X,1); figure(1); G = plot(T',X'); legend([re...

10 years ago | 0

| accepted

Answered
Problem with calculating a product of a random vector using a For loop. Help, Urgent!
RunSum = RunSum*Vect(n); : disp(RunSum) Although, I think the instructions meant for your code to use the ...

10 years ago | 1

| accepted

Answered
User defined function that fits an nth order polynomial curve to given data for values of n<30
Start with this: - Create a function m-file in your working directory: edit curvepoly.m - Put the following code into...

10 years ago | 0

Answered
xyz coordinate to angle.
doc cart2sph

10 years ago | 1

Answered
How can I calculate the standard deviation of a LARGE set of values without using the' std' or 'mean' commands?
You've got the ^2 in the wrong place in your calculation. Also, the std function uses n-1 in the denominator by default. Try thi...

10 years ago | 0

| accepted

Answered
I want this string to be different every time.
n = number of values to generate b = round(rand(1,n)); % vector randomly filled with 0's and 1's s = char(b+'0'); % a c...

10 years ago | 0

| accepted

Answered
Clarification: Array of strings vs cell array of character vectors
Generally, if you will be accessing the individual strings downstream in your code, use a cell array of strings. Many MATLAB fun...

10 years ago | 0

| accepted

Answered
randomly selecting and deleting rows from a matrix
Your code is likely not doing what you think it is doing. The randperm(427) call gives you a permutation of the numbers 1,2,......

10 years ago | 0

| accepted

Answered
Setting up my structure with a cell array of char vectors.
You are missing a special "feature" of the struct function when one of the inputs is a cell array: https://www.mathworks.com/...

10 years ago | 1

Answered
Write a function that will take two numbers as input arguments and will print a set of concentric squares of stars whenever the row and column are odd.
Here is a starting point: 1) Create a function m-file in your working directory with an appropriate name. E.g., edit myc...

10 years ago | 0

| accepted

Answered
How to make a function that loads its own input variables?
Start with this: doc save doc load Although, you could put everything in a struct and then pass that one struct (inst...

10 years ago | 0

Answered
Extracting values of a matrix in groups of 2 that move along the original matrix
Is this what you want? x(i,1:2) = A(i:i+1);

10 years ago | 0

| accepted

Answered
How to insert elements in a heap
You can clear the variables instead of initializing them to empty doubles. E.g. % ElementsToInsert = []; clear ElementsT...

10 years ago | 1

| accepted

Answered
how to get fprintf to print words with numbers
E.g., assuming provarray is N elements and taxarray is Nx2: m = max(cellfun(@numel,provarray)); for k=1:numel(provarray)...

10 years ago | 0

Answered
codegen error diff(a)~=0
mxArray variables are variables returned from extrinsic functions. There are limitations to what you can do with these variables...

10 years ago | 0

Answered
Please how do i make this while statement check all non-positive integers in the vector x below?
This checks for any non-positive values: while any(x <= 0) Did you also want to check to see if they are integers? E.g.,...

10 years ago | 1

| accepted

Answered
??? Unexpected MATLAB operator (:) when using codegen to generate C code
In place of z(:) maybe try reshape(z,numel(z),1)

10 years ago | 1

Answered
What does it mean when ~ is used as one of the outputs for a function?
It means that the particular output that would ordinarily be returned to a variable at that spot is instead discarded automatica...

10 years ago | 2

| accepted

Answered
Error: Unbalanced or unexpected parenthesis or bracket. But equation looks to be balanced. Help?
You can't have a variable or function name followed immediately by a square bracket like this: slpa[numl(slpa)] maybe yo...

10 years ago | 0

Answered
How to reolve this error? Matrix dimensions should agree..!
Use element-wise operator ./ instead of the matrix operator / r1=3./cos(theta); r2=-4./sin(theta);

10 years ago | 0

Answered
count number of values greater than threshold.
From your description: x = your x-axis values y = your y-axis values (same size as x) threshold = 30; g = x>=1 & x...

10 years ago | 1

Answered
Generating random 3D vectors
E.g., see this discussion: http://www.mathworks.com/matlabcentral/answers/306783-a-matlab-code-of-getting-a-value-uniformly-a...

10 years ago | 0

Answered
How to apply a multivariate function to each element of a vector?
Something like this? a=1; b=2; c=3; X=[-10:1:10]; fun = @(x) testf(a,b,c,x); Y = arrayfun(fun,X);

10 years ago | 0

| accepted

Answered
How can I assign/save a function output to one field of a struct across multiple elements?
[myStruct.outputField] = deal(whatever); Using the brackets on the lhs creates the multiple output requests. The deal on th...

10 years ago | 1

| accepted

Load more