Answered
Random pick data by label
A=[randi(9,100,4) randi([1 4],100,1)] % Example [ii,jj,kk]=unique(A(:,5)) m=accumarray(kk,(1:numel(kk))',[],@(x) {x'}) out...

10 years ago | 0

| accepted

Answered
Is it possible to combine two structures saved in two different .mat files?
Look at this example q=num2cell(1:2) p=num2cell(1:3) a=struct('a',q,'b',q) b=struct('a',p,'b',p) c=[a b]

10 years ago | 1

| accepted

Answered
Indexing an array with a vector
A = rand(10); v = randi(10,1,2) Why converting to cell array? just type A(v) If v is a cell array, convert it to...

10 years ago | 0

Answered
declare a function in matlab
You need to know how to call a function. Youcan't run it as a script. If you have for example this function function y=fcn(...

10 years ago | 0

Answered
Elementwise Multiply Array by Vector without repmat or loop
bsxfun(@times,A,B)

10 years ago | 1

| accepted

Answered
Simulink and doing x(k)= x(0) + 2
<</matlabcentral/answers/uploaded_files/35317/x(k-1).png>> set the initial value of x in the unit delay block

10 years ago | 0

| accepted

Answered
Read string data (date & time) from CSV file
Use [a,b,c]=xlsread('NovDay.csv')

10 years ago | 4

Answered
Transfer function by SIMULINK
<http://www.mathworks.com/matlabcentral/answers/131093-transfer-function-of-a-simple-circuit-using-simulink#answer_138902>

10 years ago | 0

Answered
how to do intersection between 3 vectors?
A = [1,3,8,5]; B = [4,1,6,8]; C= [5,8,7,1]; ABC_inter=intersect(intersect(A,B,'stable'),C,'stable')

10 years ago | 1

| accepted

Answered
How can I display the name of a cell plot?
figure; hold on a={1:10 sin(1:10) cos(1:10)} cellfun(@plot,a) leg={'fig1' 'fig2' 'fig3'} legend(leg)

10 years ago | 0

| accepted

Answered
Given Two Matrices, Match each element with the element in other matrix, export to ASCII File
A = [1 2 ; 3 4] B = [5 6 ; 7 8] a=A'; b=B'; out=[a(:) b(:)] dlmwrite('file.txt',out)

10 years ago | 1

| accepted

Answered
How to add data to an existing txt file which already contains some lines ?
a=[1 2 3;4 5 6] dlmwrite('file.txt',a,'-append','newline','pc')

10 years ago | 0

| accepted

Answered
How do I set maximum summing value
max_value=10000 bat_sum(1)=P_bat(1) for jj=2:numel(P_bat) bat_sum(jj)=bat_sum(jj-1)+P_bat(jj); if bat_sum(jj)>10...

10 years ago | 0

Answered
How to pass values between callback functions in GUI?
Use guidata

10 years ago | 0

Answered
Assign cell array of values to cell array of names
names={'a';'b';'c'} value= {1;0;1} idx=ismember(names,'a') out=value(idx)

10 years ago | 0

| accepted

Answered
Re-writing a loop including strcat in order to reduce computational time
n=5 m=10 s=regexp('A':'Z','\S','match'); out=genvarname(repmat(s(1:n)',1,m),s(1:n))

10 years ago | 0

Answered
what is the problem with my function?
I suppose you are trying to run function[T,S]=MCDK(X) The correct way is [T,S]=MCDK(X)

10 years ago | 0

Answered
I need to write multiple file names into a text file.
k=921 filename=sprintf('%d.src.bmp.txt',k)

10 years ago | 0

| accepted

Answered
How to count negative and postive values in a matrix?
s=sign(A) ipositif=sum(s(:)==1) inegatif=sum(s(:)==-1)

10 years ago | 6

| accepted

Answered
Saving a matrix into a file, saving 2 dimensional plots
A=[1 2;3 4] save filename A % use load filename to get the matrix A To save a figure, use saveas or hgsave

10 years ago | 0

Answered
Plotting two functions on graph
use hold on or plotyy

10 years ago | 0

Answered
How can i put an edge color on a specific bar?
y = [2 4 3]; b = bar(y); hold on h=bar(y(1:2)) set(h,'EdgeColor', 'red','LineWidth', 2);

10 years ago | 0

| accepted

Answered
Sum of a signal in simulink
You can use a <http://www.mathworks.com/help/simulink/slref/matlabfunction.html Matlab function block> with this code funct...

10 years ago | 0

| accepted

Answered
How to adjust axes?
<http://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html> doc ylim

10 years ago | 0

| accepted

Answered
plot function in simulink
coder.extrinsic('plot3') % not 'plot'

10 years ago | 1

Answered
How do I get a specific number of successive ones in my binary matrix?
exposure=zeros(60,96,10); [n,m,p]=size(exposure) [xx,yy]=ndgrid(1:n,1:m); randnum=cell2mat(arrayfun(@(x) x:x+2,randi([1 8],...

10 years ago | 0

Answered
Advice on Indexing A table.
a={35 '24/07/2014' 36 '08/07/2014' 38 '06/08/2014' 38 ...

10 years ago | 0

Answered
grouping data by value
A=rand(1,106); n=numel(A); [b,idx]=sort(A); m=round(n/10); p=n-m*9; ii=repmat(1:9,m,1); jj=[ii(:) ;10*ones(p,1)]; out=a...

10 years ago | 0

Answered
Why the subplot is missed after adjusting the position
Because your position are not well chosen. Try this for example a = randn(30,1); for ii = 1:4 subplot(4,1,ii) plot(a...

10 years ago | 0

Load more