Answered
How do I make a plot background black?
x=[1 2 3 4 5]; y=[10 20 30 40 50]; plot(x,y) set(gca,'color',[0 0 0])

11 years ago | 3

Answered
how to read text file into formatted array
fid=fopen('FileName.txt') tline = fgetl(fid) out=[]; while ischar(tline) out{end+1,1} =tline tline= fgetl(fid); ...

11 years ago | 0

Answered
find element of a cell or char array that matches a nonleading substring
x = {'010','030','310'} y = 'W_030_000' out=x( ismember(x,regexp(y,'\d+','match')))

11 years ago | 1

| accepted

Answered
Undefined function or method 'mtimes' for input arguments of type 'cell' ERROR
Use N=E*A/L*[-1 1]*G*[ed{:}]'

11 years ago | 0

Answered
Convert cell array into vector
a={[] [] [17] [] []} idx=find(~cellfun(@isempty,a))

11 years ago | 0

| accepted

Answered
Elegant way to create dynamically an array inside a for loop ?
d=sum(bsxfun(@times,repmat(bsxfun(@times,r',w)',1,1,10),reshape(1:10,1,1,[])),2) b=d(:,:);

11 years ago | 0

| accepted

Answered
Delete specific rows from a cell array
a={1200 'Unknown - State' 1700 'Rest' 1600 'Unknown - State' 2100 'City'} b=a(~ismember...

11 years ago | 2

Answered
Naming and using signals within block parameters?
You can do it by creating your own pulse generator, using for example Matlab Function Block or others blocks like switchs. R...

11 years ago | 0

Answered
Create a Matrix - Replace elements of a Matrix
A = [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] B=A B([randperm(8,4) randperm(8,2)+8])=1

11 years ago | 0

| accepted

Answered
how can i calculate how many number of times that 1 occurs.
x=repmat(1:4,4,1) % Example out=sum(x(:)==1) %or out=nnz(x==1)

11 years ago | 0

| accepted

Answered
??? Attempted to access nn(26,1); index out of bounds because size(nn)=[25,25].
y(1,m)=r(1,m)+nn(k,m); In this line the value of k will reach the value 26, because the size of nn is 25x25, Matlab wil...

11 years ago | 1

Answered
Selecting random points from data file
x = [1:0.1:1000]; n=randi(5)*10 out=x(n:n:end)

11 years ago | 0

Answered
Hi i have a problem with tha matlab simulink
In Matlab command windows type: mex -setup

11 years ago | 0

Answered
Matrix multiplication: exponentiation before summation
*EDIT* A=randi(5,2,2) B=randi(5,2,3) D=sum(exp(bsxfun(@times,permute(reshape(A',size(A',1),1,[]),[2 1 3]),B')),2) out=...

11 years ago | 1

Answered
GCA attributes axes changes
Use set command Example t=0:0.1:10; y=sin(t); plot(t,y); set(gca,'xlim',[0 5]) With the new version of Matlab ...

11 years ago | 0

| accepted

Answered
Why can't I plot such an easy graph?
for i = 1:100 x(i) = 1 + 2*i; y(i) = 3 + i; end plot(x,y)

11 years ago | 0

Answered
I can't make this signal as like periodic signal
T0=2; % The period Ts=0.001 % The sample time t=0:Ts:T0 x_m=heaviside(t)-heaviside(t-T0/2); plot(t,x_m,'r') % plot in on...

11 years ago | 1

| accepted

Answered
indexing must appear last in an index expression ERROR
You probably forgot an operator, maybe a prod * available(b,6)=available(i,6)*(min(find(available(i,6)*200>Le(i)==1)));

11 years ago | 0

Answered
Remove path from file name
s='C:\Users\DougAnderson\Documents\MATLAB\SHtest\sig\hole 1.xlsx' out=regexp(s,'(?<=\\)[^\\]+$','match')

11 years ago | 1

Answered
Plots return a blank window
B1=3 hmax=10 m1=10 w=1 d=4 for p=pi-B1:0.01:pi k=sin(2*pi*((p-pi)/B1)); hbiss=hmax*((2*pi)/(B1^2))*k; ...

11 years ago | 0

Answered
How can you convert an array into multiple inputs?
A= [-1 1; -2 2; -3 3; -4 4]' b=cell(1,size(A,2)) c=num2cell(A,1) [b{:}]=ndgrid(c{:})

11 years ago | 1

| accepted

Answered
Obtaining types of files in directory and put them into an array
s=dir, f={s.name} % The list of your files a=regexp(f,'(?<=\.)[^\.]+$','match') b=a(~cellfun(@isempty,a)) % list of non em...

11 years ago | 0

Answered
How to obtain similar size of subplots?
t=0:0.1:10; y1=sin(t); y2=cos(t); subplot(211); plot(t,y1); subplot(212); plot(t,y2); Where do you see different size...

11 years ago | 0

| accepted

Answered
How to use for loop for iterations.
c=[]; for i=1:3 a=rand(3,1); b=5.*(a.^2); c=[c;a b] end %or c=zeros(9,2); ii=1 for i=1:3 a=ran...

11 years ago | 0

| accepted

Answered
Averaging positive and negative values seperately for each array in a matrix
A=[0 2 2 -1 -7; 0 -1 -3 -2 6] x1=[arrayfun(@(x) mean(A(x,A(x,:)>0)),(1:size(A,1))') arrayfun(@(x) mean(A(x,A(x,:)<0)),(1:size...

11 years ago | 0

Answered
Question about diff function
a=[ 2 4 8] b=diff(a) b= [4-2 8-4] a is 1x3 and b is 1x2

11 years ago | 0

Answered
How can I sum the elements of a symbolic vector?
syms x1 x2 X = [1, x1, x2, x1^2, x2^2, x1*x2], out=char(X(1)) for k=2:numel(X) out=[out '+' char(X(k))] end

11 years ago | 0

| accepted

Answered
Extracting non-alphabets from a string
Str='G02X56.32Y13.05Z4.5F0.1' str2double(regexp(Str,'\d+(\.\d+)?','match'))

11 years ago | 0

| accepted

Answered
How to solve an equation using "solve" and get a decimal approx?
eq='x^2-2*x-7' s=double(solve(eq))

11 years ago | 1

| accepted

Answered
finding the sum across the columns in a matrix
a=[1 2;3 4] s=sum(a,2)

11 years ago | 1

| accepted

Load more