Answered
use patch to plot hexahedron with 20 nodes
Here we go [x,y,z]=ndgrid(0:2); xyz = [x(:) y(:) z(:)]; xyz(sum(xyz==1,2)>1,:)=[]; x=xyz(:,1);y=xyz(:,2);z=xyz(:,3); a=atan...

5 years ago | 2

| accepted

Answered
Simplification of two for loops
i = (1:N)'; j = 1:N; radius = sqrt((i-i1).^2+(j-j1).^2); M = (1-sin((pi*radius)/(2*radius1))).*exp(w*radius); M(radius>=radi...

5 years ago | 0

Answered
Sorting and indexing multidimensional arrays
[B,I] = sort(A,3,'descend'); I is ndarray same size as A and B, values is 1:size(A,3) such that for any i,j A(i,j,I(i,j,:)) ...

5 years ago | 1

Answered
How to use implicit model functions in Curve fitting toolbox
Why not just solving using the linear algebra, seem this straighforward method does the job xy = load('new.txt'); x = xy(:,1);...

5 years ago | 1

Answered
Is there any way to speed up the function `changem`?
Sorry; I don't speed changem up, I just remove it entirely. function TR1 = simpleTR(TR) F = TR.ConnectivityList; n = size(F,2...

5 years ago | 1

| accepted

Answered
Polynomial as product of two vectors
Try this a = [1 2 3 4 ]; syms x f = [x,x^3,x,x^3].'; a*f

5 years ago | 0

| accepted

Answered
Tall Tables and Logical Matrices
Please try this [tf,j] = ismember([zensus.FLW zensus.ZLW],[loorarea.FLW floorarea.ZLW],'rows'); i = find(tf); j = j(tf); zen...

5 years ago | 0

Answered
Newton's method for minimisation returns a critical point
"Now my question would be, is this normal with this method?" Your code juts shows it: yes it is normal. Now in practice it is ...

5 years ago | 0

Answered
Vector multiplication elementwise error
Z = B*A.';

5 years ago | 0

| accepted

Answered
Adjacency matrix of a hexagonal graph
[A,B,C] = HexGraphPart2(7,8); G = graph(A+B+C); figure; plot(G); function [H,NW,NE]=HexGraphPart2(m,n) [I,J]=ndgrid(1:m,...

5 years ago | 0

| accepted

Answered
I have a non-convex function and want to approximate/relax to convex function, can provide a solution?
One way: select any point of your curve, compute the taylor expansion; set all odd terrms + negative even terms (excepts constan...

5 years ago | 1

Answered
How can I get the first and last letters out of each word?
Fix few things in your code function ca = makeKeyArray(str) char=isletter(str); for k=1:length(str) if strcmp(str(k),'''...

5 years ago | 1

Answered
How to get random values from a matrix
rcols = randperm(size(A,2),5); B = A(:,rcols)

5 years ago | 1

Answered
Volume from 3d point
You'll get the volume of the convex hull by [~,V] = convhull(X,Y,Z)

5 years ago | 0

| accepted

Answered
How to solve a first order partial differential equation
u(x,y) = x + x^2*y + cosh(y)

5 years ago | 0

| accepted

Answered
Why Matlab becomes 100 time slower using vector?
I guess for-loop withh vector benefits MATLAB jit accelerator. But here is a faster method if you insist on using matrix. func...

5 years ago | 0

Answered
Fast operations between matrix
A = rand(52,3) B = rand(3,1) S = A-B.'

5 years ago | 1

Answered
How to better use cells?
Convert to array like this after the while loop Ya = cell2mat(Y); Ytograph = Ya(2,:); plot(t, Ytograph) Yead you guys just m...

5 years ago | 0

| accepted

Answered
accuracy of eigenvalue calculation
"Why the eigenvalues are different? Shoudn't they be the same? " Because solving for e of equation using determinant det(A0+d...

5 years ago | 1

Answered
Is there a way to get a 'less than or equal to' symbol in to a text document?
To keep standard font text(.2,.2,['3 ' char(8804) ' 4']) text(.3,.3,['3≤4 (default)']) % if your editor is configured to suppo...

5 years ago | 2

Answered
GUI - Align "Distribute" option does not work
"I would like to uniformly distribute the two pushbuttons inside the panel on the vertical dimension, but the align "distribute"...

5 years ago | 2

| accepted

Answered
how to find possible combinations
% Test data A=rand(32,10); [m,n]=size(A); I=nchoosek(1:m,4).'; % Each slice B(:,:,k) is a 4x10 (without-replacement) combi...

5 years ago | 0

| accepted

Answered
What is missing from MATLAB #2 - the next decade edition
Implement equivalent to C inline-function (or macro) so as calling this function on small data won't be penalized in speed with ...

5 years ago | 0

Answered
Define a new structure from another one
fname = fieldnames(STR) S.P = STR.(fname{1}); % S = struct('P', {STR.(fname{1})})

5 years ago | 1

Answered
What is missing from MATLAB #2 - the next decade edition
Implement family of (numerical) data structure with O(1) inserttion, removal, that includes chain-list, binary tree, Fibonachi t...

5 years ago | 0

Answered
Error using optimoptions (line 124)
Make sure you have optimization toolbox installed >> ver ---------------------------------------------------------------------...

5 years ago | 0

Answered
How to convert 8 bytes to a double value
>> typecast(uint8([147, 190, 144, 143, 145, 126, 68, 64]),'double') ans = 40.9888

5 years ago | 0

| accepted

Answered
Distinguish between ASCII and Binary
I don't know if it's an elegant way but I just test if any charater is > 255 fid = fopen(stlfilename,'rt'); if fid > 0 tr...

5 years ago | 0

| accepted

Answered
FMINCON first order optimality non-zero
If the blackbox you use does some weird stuff such as thresholding, branching, truncation ... that in turn makes your cost funct...

5 years ago | 0

Answered
How to include a *.lib file when I use mex to transform Fortran code to mexw file?
Lib file must used in conjunction with -L -l options. Please read the doc of MEX command

5 years ago | 0

Load more