Respondida
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...

casi 7 años hace | 1

| aceptada

Respondida
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...

casi 7 años hace | 0

| aceptada

Respondida
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 ...

casi 7 años hace | 0

Respondida
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]; % <- ...

casi 7 años hace | 0

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

casi 7 años hace | 0

| aceptada

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

casi 7 años hace | 0

Respondida
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...

casi 7 años hace | 0

| aceptada

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

casi 7 años hace | 0

Respondida
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...

casi 7 años hace | 2

| aceptada

Respondida
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,:); ...

casi 7 años hace | 0

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

casi 7 años hace | 1

| aceptada

Respondida
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...

casi 7 años hace | 1

Respondida
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);

casi 7 años hace | 1

| aceptada

Respondida
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...

casi 7 años hace | 1

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

casi 7 años hace | 0

| aceptada

Respondida
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...

casi 7 años hace | 0

Respondida
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...

casi 7 años hace | 4

Respondida
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 .* ([...

casi 7 años hace | 0

Respondida
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...

casi 7 años hace | 1

| aceptada

Respondida
How do you chop a number to a specified number of significant digits, not round
2 digits fix(x*100)/100

casi 7 años hace | 2

Respondida
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...

casi 7 años hace | 0

Respondida
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; %...

casi 7 años hace | 1

| aceptada

Respondida
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...

casi 7 años hace | 1

Respondida
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...

casi 7 años hace | 0

| aceptada

Respondida
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(:))

casi 7 años hace | 1

Respondida
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); ...

casi 7 años hace | 0

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

casi 7 años hace | 0

| aceptada

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

casi 7 años hace | 0

| aceptada

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

casi 7 años hace | 0

| aceptada

Respondida
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...

casi 7 años hace | 0

| aceptada

Cargar más