Answered
Vectorized method to find the number of consecutive 1s from the left of an array
idx=find(diff(A)); if A(1)==0 Result=0 elseif all(A) Result=numel(A) else Result=idx(1) end

7 years ago | 1

| accepted

Answered
How to control x-axis range
xlim([0 100]) xticks(0:20:100)

7 years ago | 2

| accepted

Answered
How can I plot a solid 3-D cube of unit dimension in matlab?
gm=multicuboid(1,1,1); model=createpde; model.Geometry=gm; pdegplot(model)

7 years ago | 0

Answered
how do i place a matrix on top of each other using repmat
z1=zeros(5); z2=ones(5,10); z3=repmat(0:14,5,1); % proper usage Result=[z1 z2;z3] % concatenate z1 , z2 horizontally & z3 ve...

7 years ago | 0

| accepted

Answered
How to plot ?
doc fplot

7 years ago | 0

| accepted

Answered
Line thickness 'invalid data argument' error
plot(x,f,'r','LineWidth',3) hold on plot(x,fh,'b','LineWidth',1)

7 years ago | 1

Answered
Split numeric values of vector with NaN to individual matrices
Note: In your question the first NaN should be NaN not Nan because NaN is valid in Matlab. M = [ 1 ; 2 ; 4 ; 4 ; 2 ; NaN ; NaN ...

7 years ago | 0

| accepted

Answered
integral and derivatives of a function
Your way , see https://www.mathworks.com/help/matlab/ref/diff.html#btw_sz6-1 : clc clear inta3=integral(@a3,0,5); x=0:0.1:5...

7 years ago | 0

Answered
integral and derivatives of a function
clc clear inta3=integral(@a3,0,5) syms x % requires symbolic toolbox Ax=a3(x) diffa3= diff(Ax)/x % remember diff(Ax) is on...

7 years ago | 0

| accepted

Answered
indexing to find elements between 2 values in a matrix
B=M6<0 | (M6>29 & M6<33)

7 years ago | 0

| accepted

Answered
problem with integration of a function
yb = 10*x.^2.*exp(-2*x).*(sin(3*x-pi)+cos(x.^2)) % ^--- missed it

7 years ago | 0

| accepted

Answered
tring to plot the 3d and contour levels of a function
clc clear x=-pi:0.1:pi/2 y=-pi:0.1:pi; [xx,yy]=meshgrid(x,y) zz = cos(2*yy-x).*sin(2*xx); % ^------------^------ m...

7 years ago | 0

| accepted

Answered
fmincon - Not Enough Input Arguments
x0 = [-1,2]; A = [1,2]; b = 1; x = fmincon(@z1_test,x0,A,b) % ^------ missed it function f2 = z1_test(x) f2 = ...

7 years ago | 1

| accepted

Answered
Legend is not working!
plot(I,repmat(12,1,numel(I)),'-rx') plot(repmat(0.1,1,numel(V3)),V3,'-bo')

7 years ago | 0

| accepted

Answered
How do I get the lengths of each entry in a cell array without using a loop
cellfun(@length,ca)

7 years ago | 0

| accepted

Answered
do you have some videos about tables in Matlab?
I can share some links of documentation and blog which are quite helpful: https://www.mathworks.com/help/matlab/matlab_prog/cre...

7 years ago | 0

| accepted

Answered
Use of handle in matlab 2013b
%%%% The below can be in a command window or in a separate script file h = counter ; % function call h(0) % ^----- x is zero ...

7 years ago | 0

Answered
How to combine te same elements in table
Requires 2018a or later: a=[ 1 1 24 1 52 1 53 4 % element 53 occurs 4 times 53 3 % the...

7 years ago | 1

Answered
Conversion of an matrix array
Second way: matrix(:).'

7 years ago | 0

Answered
Save each loop values, without overwriting
https://www.mathworks.com/help/matlab/matlab_prog/preallocating-arrays.html - essential for a loop and see how the variables are...

7 years ago | 0

Answered
Conversion of an matrix array
reshape(matrix,1,[])

7 years ago | 0

| accepted

Answered
I can not use the " lhs " instruction,but it seems that lots of people can use it.What is the problem ?
https://www.mathworks.com/matlabcentral/answers/438815-why-is-the-lhs-function-including-the-example-posted-in-the-mathworks-doc...

7 years ago | 0

Answered
how to split num to str ?
It’s possible using symbolic math toolbox. syms x y y=-x-2 coeffs(y)

7 years ago | 0

Answered
Graph looks like a dotted straight line
tb=(I*m*tl)./(2*u*q.*a) % is equivalent to (I*m*(2*u*q.*a))/(I*m*2*u*q.*a)) so everything gets cancelled out , you will have a ...

7 years ago | 0

| accepted

Answered
Group all the columns every N rows
Your way: N=2; A=mat2cell(a,repelem(N,size(a,1)/N)); celldisp(A)

7 years ago | 1

| accepted

Answered
Group all the columns every N rows
One way: N=2; [~,c]=size(A); U=reshape(A',c,N,[]); R=permute(U,[2 1 3])

7 years ago | 0

Answered
the value of my volume_bar function is shown to be incorrect. what am i doing wrong?
Volume_of_bar=pi*(d/2)^2*Length https://simple.wikipedia.org/wiki/Cylinder#Common_use

7 years ago | 0

| accepted

Answered
put all cells in one column cellfun
out= cellfun(@(w,e,r)[w;e;r],q1,q2,q3,'uni',0); % ^-----^------- square bracket!

7 years ago | 0

| accepted

Answered
Saving a text file with strings stored in cell array
for k=1:numel(a) dlmwrite(sprintf('%s.txt',a{k}),data) % can be any exporting command save , writetable etc etc. % ^^^^...

7 years ago | 0

| accepted

Load more