Answered
Simulation throwing of two dice?
histogram(sum(randi(6,2,input('number of throws'))));%assuming you want the sum of the dice plotted

6 years ago | 1

| accepted

Answered
Find Derivative of Numeric Function
I am not sure what the best way is, but I would use symbolic and then convert. syms x; f=x^3; df=str2func(['@(x)',char(diff(f...

6 years ago | 1

Answered
Solving equations by calling a function
function B=eqnB(E,F) fun=@(b)b*tanh(b)-E*F; B=fsolve(fun,1); end

6 years ago | 0

| accepted

Answered
Find intervals in a vector
a=find(A~=0); b=[0,find(diff(a)>1),length(a)]; for k=2:length(b) c{k-1}=a(b(k-1)+1):a(b(k)); end

6 years ago | 0

| accepted

Answered
How to use quadratic formula to find the values?
wn=sqrt(roots([100 -1.15e4 2.7e5]));

6 years ago | 0

Answered
Operator '==' is not supported for operands of type 'tf'
if tf %already logical end

6 years ago | 0

Answered
Finding the magnitude of an expression
I would not use symbolic unless you need to. x = @(t)0.113*sin(3.0*t) - 0.125*cos(3.0*t) + 0.125*exp(-0.25*t).*cos(3.15*t) - 0....

6 years ago | 0

Answered
How to add individual digits
U = sum(input('Please enter a code to break:','s')-'0');

6 years ago | 0

Answered
How to create a double array from a cell array
Why not just: cell2mat(yourCellarray);

6 years ago | 1

Answered
How to remove some data from the plot?
a=yourArray; k=2; while k<=length(a) if a(k)<=a(k-1)&&a(k)+40>a(k-1) k=k+1; else a(k)=[]; end end

6 years ago | 1

| accepted

Answered
How to write a for loop code with an undetermined value
What are you trying to plot? What is M? [n,nn,nnn]=unique(N);%;might want to look at the outputs here, they might help you

6 years ago | 0

Answered
Line 21 giving me troubles
time=z*r1*(sqrt((2*m)./(q*V)))*(1+(z/3)+(z^2/10)+(z^3/42)+(z^4/216));%just need ./ since V is an array

6 years ago | 0

| accepted

Answered
Random numbers and storing from 1 -5
y=zeros(5,600); for k=1:600 y(:,k)=randperm(5); end

6 years ago | 1

Answered
Combine multiple vectors into specific locations of one matrix
You can't leave the first column empty. Why not put zeros in? a=[6 6 6 6 6 6 99 99 99 99 99 99]'; b=[111 112 127 123 211 218 2...

6 years ago | 1

| accepted

Answered
Average of array elements of the order 1*281*24
m=mean(squeeze(yourMatrix));

6 years ago | 0

| accepted

Answered
How to convert a matrix into a vector that has each row as an array?
I assuming you want a cell array a=yourMatrix; newCellarray=mat2cell(a,ones(1,size(a,1)),size(a,2));

6 years ago | 0

Answered
How to write a code for a distribution?
mu=mean(r); alfa=input('alfa is considered as:') beta=input('beta is considered as:') K=input('k is considered as:') g(r)=be...

6 years ago | 0

| accepted

Answered
how to fill the interior of a closed surface?
Look at polyshape() (assuming your have the coordinates of your surface) pgon = polyshape([0 0 1 3], [0 3 3 0]); a=plot(pgon);...

6 years ago | 1

Answered
How to remove the horizontal line at 0
x=1:10; y=randi(20,1,10)-10; b=bar(x,y); ax=gca;%to access axes properties hold on plot(x,y,'r*--') b.ShowBaseLine='off'

6 years ago | 0

| accepted

Answered
Nested Loop, Can someone help me to understand this code?
function Y = mycumsum(X) Y = X; [r,c] = size(Y); %determine size of maxtrix for ii = 2:r %1st row will stay constant, start ...

6 years ago | 1

| accepted

Answered
Matrix index is out of range for deletion.
What are you trying to do? V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]; V8=V2(1:2:end);

6 years ago | 0

Answered
How to stack k copies of a matrix
a=reshape(repmat(A(:),k,1),[size(A),k]);

6 years ago | 0

Answered
'Dot indexing is not supported in import data type'
newdata is a 1x1 cell array. I assume inside the cell is a x by 3 matrix. Try this: idata=newdata{1};%replaces idata=newdata.da...

6 years ago | 0

| accepted

Answered
4*4 diagonally dominant matrix
If you want to randomly generate, I would just generate a random 4x4 and then check whether it was diagonally dominant. a=randi...

6 years ago | 0

Answered
Yes or No question using while loop
while 1 base = input('enter base of beam'); height = input('enter height of beam'); A = base*height disp(['T...

6 years ago | 1

| accepted

Answered
solving set of non linear equation
function F = root2d(phi) beta_a = 10; alpha_n = 10 ; eta = 18; i = 18; theta_i = asind(sind(beta_a)*sind(eta)); theta_n = ...

6 years ago | 0

Answered
Combine each column of two array side by side and add new column to new array
array1=array1'; array2=array2'; array3=array1+array2; newArray=reshape([array1(:),array2(:),array3(:)]',9,[])';

6 years ago | 0

Answered
Cell arrays inside a structure array - how to access and perform operations?
I did not put x and t back into a struct. a=find(ismember(isnan(results.timestamps),[1 1],'rows'),1)-1;%delete rows after x=re...

6 years ago | 1

| accepted

Answered
Convert a cell with structures into a matrix
m=[]; for k=1:3 m=[m;A{k}.data]; end

6 years ago | 0

Answered
receiving orbitrary function from user
Look at str2func f=str2func(input('Input a function of a single variable to be graphed [e.g., @(x)x.*cos(x)-x.^2.*sin(x)]','s')...

6 years ago | 0

Load more