Answered
Ellipsoid plot_ wireframe view
[Q,~] = qr(randn(3)); h = rand(3,1); h1 = h(1); h2 = h(2); h3 = h(3); % If your principal axis are (3x1) P1, P2, P3 and h...

6 years ago | 1

| accepted

Answered
How can I multiply two big matrices, avoiding out of memory?
You can process by chunk of smaller (100 here); % Generate small test data m = 100; n = 100^2; C = rand(m^2,3); % your [alph...

6 years ago | 0

| accepted

Answered
How to sort a matrix's columns by using indexes
Short answer data = data(:,indA); Long answer load lung.mat data=lung; b = data(:,end) == 1; data1 = data(b,:); data2 ...

6 years ago | 0

Answered
Switching an array of Vectors from Cartesian to Spherical Coordinates
OK since nobody care to give you the complete commands I'll [az,el,r] = cart2sph(V(1,:),V(2,:),V(3,:)); S = [az; el; r]; % <- ...

6 years ago | 0

Answered
Minimum and maximum values of a field in a structure array
arrayfun(@(s) min(s.f1), s)

6 years ago | 0

| accepted

Answered
Row with means of each column in matrix
A = [A; mean(A,1)]

6 years ago | 0

Answered
Matlab Gui Column Calculation Problems adds 48
Convert your GUI Data input using str2double, str2num etc >> str2double('0')+1 ans = 1 >> '0'+1 ans = 4...

6 years ago | 0

| accepted

Answered
Sorting specific values of one matrix into another
Why not use Connected graph component?

6 years ago | 0

Answered
How to get the longest consecutive values in a column vector and the position at which it starts
A=[0 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1]' i=reshape(find(diff([0;A;0])~=0),2,[]); [lgtmax,jmax]=max(diff(i)); istart...

6 years ago | 2

| accepted

Answered
I want the code to randomize the rows and present each row for 10 times
The array B of the below has exactly 10 times each row of A in random order: m = size(A,1); B = A(mod(randperm(10*m),m)+1,:); ...

6 years ago | 0

Answered
Generate matrix that is a product of its indices
n = 5; i = (1:n)'; j = 1:n; M = i.*j - (i+j)

6 years ago | 1

| accepted

Answered
permutations of a matrix
x = (1:5)'; n = size(x,1); m = 5; % size of b s = 3; % target sum(A(:)) [i,k] = ind2sub([m,n],nchoosek(1:m*n,s)); j = re...

6 years ago | 1

Answered
how do I improve this code?
x = [2 5 6 7 8]; y = [1 3 4 8 9]; z = x.*y; z(10) = 0; c = cumsum(z);

6 years ago | 1

| accepted

Answered
How to close the boundary of a surface already generated by filling the holes
Add the salt to suit your need Aorg = xlsread('Y_slice.xlsx'); gapmax = 5; % adjust to your need [m,n] = size(Aorg); A...

6 years ago | 1

Answered
simple integration calculation to find the area ?
trapz(T,V)

6 years ago | 0

| accepted

Answered
determine combination of elements in matrix
lgt = 4; % number of elements nz = 2; % number of 0s j = nchoosek(1:lgt,lgt-nz); i = repmat((1:size(j,1))',[1 size(j...

6 years ago | 0

Answered
Copy a figure to a subplot including all elements
close all fig1 = figure(1); ax = axes('parent',fig1); h=plot(ax,rand(1,10)); xlabel(ax,'x'); ylabel(ax,'y'); title(ax,'s...

6 years ago | 4

Answered
Plot of an ellipsoid
% If your principal axis are (3x1) P1, P2, P3 and half length are (scalars) h1, h2, h3 Q = [P1(:), P2(:), P3(:)]; Q = Q .* ([...

6 years ago | 0

Answered
Find the angle between two points in 3D plot.
if the 3D (x-y-z) coordinates of your two points are P1 and P2, both are (3 x 1) or (1 x 3) vectors angleradian = acos((P2(2)-P...

6 years ago | 1

| accepted

Answered
Using maximum of optimisation variable as an upper bound for another variable
Not sure what you mean by "boundary condition" (there is no such thing in all optimization frameworks as far as I know), but tak...

6 years ago | 0

Answered
Draw partial spheroid include a spheroid
The code bellow us this FEX to generate mesh points. % radius of the inner/outer spherical parts r1 = 1; r2 = 2; n = 20; %...

6 years ago | 1

| accepted

Answered
How to trim segments to fit a square
% Generate some test data, put 100 instead of 20 if you like X1=rand(20,1)*40; X2=rand(20,1)*40; Y1=rand(20,1)*60-10; Y2=r...

6 years ago | 1

Answered
Create volume out of two surfaces
Tetra mesh generation. Let you do exportation in STL file % Points in xy-plane nx = 100; px = linspace(1,50,nx); pyi = 5+s...

6 years ago | 0

| accepted

Answered
pairs of consecutive numbers
A=[5 3 4 1]; As=sort(A); b=diff(As)==1; pairs=As(b)'+[0 1]; notpair = setdiff(A,pairs(:))

7 years ago | 1

Answered
How can I rotate and reflect subplots as a group?
x = rand(5,9); y = rand(5,9); c = rand(5,9); close all % Normal figure for h=1:9 [m,n] = ind2sub([3 3],h); ...

7 years ago | 0

Answered
how to add all 2d matrices in a 4D matrix???
sum(sum(A,3),4) or sum(A(:,:,:),3)

7 years ago | 0

| accepted

Answered
Calculation of unknown values of two equations without Symbolic Math toolbox
C = [1 1; -3 -2] \ [29; -70]

7 years ago | 0

| accepted

Answered
Multiplying 3D matrices
There is no stock function (what a MATRIX LABORATORY doesn't have such feature?), but here it is MTIMESX

7 years ago | 0

| accepted

Answered
How to round up components of a matrix to 1
>> A=[0.818655843258541 0.381356605388963 0.286089112378312 -0.0340005479718328 0.0773489731425248 -0.0465565535336793 -0.0390...

7 years ago | 0

| accepted

Load more