Answered
For loop with if and elseif statements
You can use continue https://www.mathworks.com/help/matlab/ref/continue.html

5 years ago | 0

| accepted

Answered
Inserting zero intensity value in a patch of an digital image.
Suppose it is a 16 by 16 patch. For a rectangular region, you can just use simple subscript indexing to set those pixels to z...

5 years ago | 0

| accepted

Answered
Mean of every 5 columns of an image
Using sepblockfun (Download), newImage = sepblockfun(yourImage(:,1:255),[1,5],'mean'); imshow(newImage)

5 years ago | 2

Answered
Multiplying structure array with a scaler
If you mean you want to multiply all the fields by 2, s0.a=1;s0.b=2;s0.c=3 %example struct s=structfun(@(f)2*f, s0,'uni',0)

5 years ago | 2

| accepted

Answered
Fill() for multiple polygons with specified colors -- weird behavior?
I guess you have to explicitly override the CDataMapping. x1 = [ 1 1 2 2]; y1 = [ 1 2 2 1]; x2 = [ 3 3 4 4]; y2 = [3 4 4 3...

5 years ago | 0

Answered
How do I vectorize a function with intermediate range vector
Maybe this is what you had in mind: my_function([1,2,3]) function result = my_function(a) result = arrayfun( @(n)sum((-...

5 years ago | 0

Submitted


Analyze N-dimensional Convex Polyhedra
Find vertex or (in)equality forms of convex polyhedra in R^n (for n not super large). Also, compute their intersections and unio...

5 years ago | 6584 downloads |

5.0 / 5
Thumbnail

Answered
How to efficiently do grouped subtraction?
Using sepblockfun from the File Exchange, yt=gpuArray(yt); at=gpuArray(at); f=sepblockfun(yt,size(at),'sum')-sum(at);

5 years ago | 0

Answered
How do I vectorize a function with intermediate range vector
my_input = [1, 2, 3]; my_function(my_input) function result = my_function(n) result = n.*(n + 1).*(2*n + 1)/3; end

5 years ago | 1

| accepted

Answered
How to find the sum of values of a function at mid point of every subinterval?
If your function is vectorized, like in the following example, it is quite simple: fun=@(tm) tm.^2+ sqrt(tm); %A vectorized fun...

5 years ago | 0

| accepted

Answered
how to slice variables to use parfor
One way, [I,J,S]=deal(cell(tot_cols,1)); parfor k=1:tot_cols idx = randi([1 tot_rows], randi([1 tot_rows]), 1); %...

5 years ago | 1

| accepted

Answered
Help!!! Least square fitting
Using fminspleas from the File Exchange, P = flip([175.2582 150.9053 103.9622 69.9965 48.6696]).'; D = flip([0 31.33...

5 years ago | 1

| accepted

Answered
simple math with wrong results results
Use ./

5 years ago | 1

| accepted

Answered
All possible Permutations for vector
V=[3,3,5]; n=numel(V); Vc=cellfun(@(x) 1:x, num2cell(V), 'uni',0); [C{1:n}]=ndgrid(Vc{:}); out=reshape( cat(n+1,C{:}) ...

5 years ago | 0

| accepted

Answered
How to display @linprog iterative output
Here is a somewhat acrobatic way of extracting and plotting the objective values. Unfortunately, they can only be extracted to t...

5 years ago | 0

| accepted

Answered
Create a subclass in subfolder
If all the classes and sub-classes are completely contained in their own classdef mfiles, then it doesn't matter where within yo...

5 years ago | 0

| accepted

Answered
How to solve for non linear equations with unknown variables
You can rewrite the equations as linear with the change of variables c1=(b_0.^2-2.*b_0) and c2= -1/b1, Equ_i = c1+c2*D_i == -P_...

5 years ago | 1

Answered
How to convert a layered structure into arrays.
Here's a way you can recursively search down through a tree of nested structs. Since I don't know how you want to handle multipl...

5 years ago | 0

| accepted

Answered
How to convert a layered structure into arrays.
A more automated option, f=string(num2cell('a':'z')); for i=1:13 B(i)=A.( f(2*i-1) ).( f(2*i) ).first; C(i)=...

5 years ago | 0

Answered
use of nlinfit for nonlinear fit
I assume you want to save all 1500 estimates? If so, your loop should assign the outputs to a particular location in beta, whic...

5 years ago | 0

Answered
How do I do permutation in matlab with all possible positive and negative combinations
[C{1:3}]=ndgrid([-1,1]); C=reshape(cat(4,C{:}),[],3); B=perms(3:-1:1); clear A for i=3:-1:1 A(:,i)=kron(B(:,i),C(...

5 years ago | 0

| accepted

Answered
Fitting Cumulative Gaussian Function to Data Points
Your data points don't look anything like a CDF to me (no monotonic trend of any kind), but one of the estimated parameter value...

5 years ago | 0

| accepted

Answered
how to compute the mean value of non-zero elements in each row of a sparse matrix
rowmeans = sum(C,2)./sum(logical(C),2);

5 years ago | 1

Answered
how can i join GUIs together?
One solution might be use tabbed panels https://www.mathworks.com/help/matlab/ref/uitab.html

5 years ago | 0

| accepted

Answered
Array operation shift values
values=[3,5,1]; A=[0 0 0 0 0 ]; for i=1:numel(values) A=[values(i), A(1:end-1)] end

5 years ago | 0

| accepted

Answered
Subscript indices must either be real positive integers or logicals.
I don't get errors, as long as i is a real loop counter. w=linspace(-20,20,50); T= linspace(0,1,50); for i=1:50 F(i)=(1-...

5 years ago | 0

Answered
Comparing arrays within a struct
[total_max,idx]=max( max( vertcat(Max(:).data) ,[],2) ); Max(idx).title

5 years ago | 1

| accepted

Answered
Alternate form of eval function
Why not simply I(i,j,k)=getsiganl(filename1); II(i,j,k)=smooth(sum(I(i,j,k),2)) Be mindful though that if i,j,k are scalar co...

5 years ago | 0

Answered
Transform 3D point cloud
Funny. Well, you can always use affine3d, rot=[ -0.48664090 0.36675647 0.79288739; -0.67601788 -0.73296887 -0.07587120...

5 years ago | 0

| accepted

Load more