Answered
Bug with max function
Check in your script that A and B are the same size, in command windows type size(A) size(B)

11 years ago | 0

Answered
Scope in Simulink does not display waveform correctly
I suppose your sample time is very small, in the *scope parameters-history* uncheck *limit data point to last* <http://www.ma...

11 years ago | 3

| accepted

Answered
Replacing NaN cell array values with empty values
A=[8 10 5 -9 NaN]; A=transpose(A); A=num2cell(A) A{5,1}=' ' %or better A{5,1}=[]

11 years ago | 0

Answered
Are there xdata and ydata properties for fill command?
x=[0 10 10 5 0 ] y=[0 0 2 1 2 ] h=fill(x,y,'r') get(h,'xdata') get(h,'ydata')

11 years ago | 0

| accepted

Answered
How can I run a M-file with Simulink model in the same time and this M-file takes Simulink model data from workspace per each time step ?
You can use <http://www.mathworks.com/help/simulink/slref/interpretedmatlabfunction.html Interpreted Matlab function block> or <...

11 years ago | 0

| accepted

Answered
Extract coordinates from a significance matrix
a=randi([0 1],19) % Example [ii,jj]=find(a) out=[ii jj]

11 years ago | 0

| accepted

Answered
How to Plotting a Binary input?
d = 89 byte = dec2bin(d) %Plotting Input signal stairs(byte-'0','r','linewidth',5)

11 years ago | 0

Answered
How to use a vector as indices for matrix?
V= [3 1 1 5 4] m=numel(V); n=max(V) idx=sub2ind([n m],V,1:m) out=zeros(n,m) out(idx)=1

11 years ago | 3

| accepted

Answered
trouble with converting dec2bin
x=[1 3 5 7]; outx=dec2bin(x)

11 years ago | 0

| accepted

Answered
Help with assignment on functions
function x=cost(a) This mean you are calculating x depending on the value of a. In your code x is not calculated. You shoul...

11 years ago | 0

Answered
importdata no recognizing column headers
s=importdata('file.txt') h=strsplit(s.textdata{:}) data=s.data n=size(data,2) out=[h(1:n);num2cell(data)]

11 years ago | 2

| accepted

Answered
How can I make the dimensions agree for this function
f = @(x) x.' - exp(cos([1:4]*sum(x)))

11 years ago | 1

| accepted

Answered
calling corresponding elements of two matrices
A = [1, 2, 3; -1 -5, -3; 0, -2, 4] B=A.^2 [M,ii] = max(B, [], 2) out=A(sub2ind(size(A),1:size(ii,1),ii'))

11 years ago | 0

| accepted

Answered
How to break and integer into an array output.
a=9876; b=num2str(a)-'0'

11 years ago | 9

Answered
Fitting vector of n length
u=[1 2 3 4 5 6 7 8 9 10]' n=numel(u) x=u(1:n); phi=[x.^2 x ones(n,1)] %or phi=bsxfun(@power, repmat(u(1:n),1,3)...

11 years ago | 0

| accepted

Answered
What is the function I must use to search variables in workspace?
There is no files in workspace, you can use dir to search files in a current folder

11 years ago | 0

Answered
Pairwise summation of two vectors?
a=[1 2 3] b=[4 5 6 7] c=bsxfun(@plus,a.',b)

11 years ago | 2

| accepted

Answered
how can i convert excel file to mat file
[a,b,c]=xlsread('yourfile.xlsx') save yourmatfile c

11 years ago | 6

| accepted

Answered
Can I plot 5 y-axis?
Try to adapt this code to your problem % ------------------your 6 functions----------------------------------------- x=0:...

11 years ago | 4

| accepted

Answered
How to find response
A = [3 0;0 -2]; B = [3 0;0 -2]; C = [-1 1;1 -1]; D=0; x0 = [1 -1]; poles = eig(A) % You have unstable poles (pole=3) %...

11 years ago | 1

| accepted

Answered
problem with XOR bits
N=8; r=3 A=zeros(N,r) out=zeros(N,1) for k=0:1:N-1 A(k+1,:)=dec2bin(k,r)-'0' out(k+1,1)=xor(xor(A(k+1,1),A(k+1,2...

11 years ago | 0

| accepted

Answered
converting only certain cells to a matrix
a = { rand(1877958,7); rand(1251972,7); rand(4564357,7) }; n=max(cellfun(@(x) size(x,1) , a(1:2)) ) b=cell2mat(cellfun(@(x...

11 years ago | 2

| accepted

Answered
message "vectors with different lengths"
You are trying to plot plot(teta,s) teta and s should be the same size, in your case, type numel(teta) numel(s) ...

11 years ago | 1

Answered
Derivative after integration issue.
If you use these two blocks <http://www.mathworks.com/help/simulink/slref/derivative.html derivative block> and <http://www.math...

11 years ago | 0

| accepted

Answered
in matlab what actually do you mean by the error index exceeds matrix dimensions ?
For example if you have an array a containing 3 elements a=[1 2 3] If you write a(4) a does not contain 4 eleme...

11 years ago | 1

Answered
How to rearrange subsystem block ports?
Use this code to get the different ports then use delete_line and add_line to arrange them b=get_param('untitled/yoursubsys...

11 years ago | 1

| accepted

Answered
adding strings per component
This is not a good idea, read this <http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3...

11 years ago | 0

| accepted

Answered
How to make the second case working in the following matlab file ?
syms t x syms x0 v0 syms m c k equ = 'm*D2x + c*Dx + k*x = 0'; ic1 = 'x(0) = x0'; ic2 = 'Dx(0) = v0'; x2 = dsolve(equ,ic...

11 years ago | 0

Answered
fastest way to read in every m lines of a file sequentially?
fid=fopen(myfile) k=0; a=cell(1,100) while ~feof(fid) k=k+1 a{k}=fgetl(fid) if mod(k,100)==0 %do yo...

11 years ago | 0

Answered
Index must be a positive integer or logical
Check your indices, if a is an array you can't write a(1.8) the index must be a positive integer or logical

11 years ago | 0

Load more