Answered
Simple rounding numbers in a matrix
A=2*rand(5)-1 % Example A(A<-0.5)=-1; A(A>0.5)=1; A(-0.5<A & A<0.5)=0

14 years ago | 1

| accepted

Answered
Stopping my function from doing iteration (infinite while loop)
function y = mysqrt(x,y0,tol) y = (y0 + (x/y0))/2; y = (y + (x/y))/2; while abs(y^2-x)>tol y = (y + (x/y))/2 en...

14 years ago | 1

| accepted

Answered
fast way of filing up a matrix with function calls
M=rand(4); % your matrix f=@(x) sin(x)*x % your function out=arrayfun(@(x) f(x),M) Or you can...

14 years ago | 0

Answered
how I can solve a linear system AX = B type, if one of the B vector data change constantly, in simulink
You can use a Matlab function block with three inputs: one from a constant block with value set to matrix A, another from a cons...

14 years ago | 0

Answered
smallest n such that vector(n) < a
v=[10 12 4 5 9 20] idx=find(v<5,1)

14 years ago | 0

Answered
How to find the x value from cumsum
x=1:10 y=cumsum(x) % for y=15 x0=x(find(y==15))

14 years ago | 0

Answered
How to store results from every loop in For-Loop
for k = 1:21 Intensity = imread(filelist(k).name); for c = 1:6 P_Centro_1 = impixel(Intensity,(center(c,1)...

14 years ago | 0

| accepted

Answered
simulation inside a "for loop" for stop time
Arun, I've tested an example, and find some problems, when you pause or stop your simulink model, the output variable takes a ce...

14 years ago | 0

Answered
Insert image into Report Generator
In your report rpt file use a for loop where you will load and open with imshow your images (one image every loop) and add a fig...

14 years ago | 0

| accepted

Answered
How to read several excel files (30 files) without repeating the program?
fic=struct2cell(dir('yourfolder/*.xls')) file=fic(1,:) for k=1:numel(file) data{k}=xlsread(file{k}) end

14 years ago | 0

Answered
Adding symbolic matrices along 3rd dimension
clear Q syms a b c d e f g h i Q(:,:,1) = [ a b c;d e f;g h i] Q(:,:,2) = [ a, d, g;b, e, h; c, f, i] [n1,n2,n3]=size...

14 years ago | 0

| accepted

Answered
How can i use the 'mod' function in an Embedded Matlab function?
In the below part of your code while u~=0 newu=newu*10+mod(u,10); u=(u/10); nr=nr+1; end; |newu| increases rapi...

14 years ago | 0

Answered
Write some equations as product between function-matrix and constant-matrix
K*X=Z %with: K=[0 m n 0;b 0 0 c] X=[x;x^2;y;y^2] Z=[z1;z2]

14 years ago | 0

Answered
C code generation, "unknown complier" occured
You have to chose your compiler. In Matlab command mex -setup Then choose your compiler

14 years ago | 0

| accepted

Answered
Index exceeds matrix dimensions when using end
Look at this example visitcount={rand(9,8) rand(9,8,7,6) rand(9,8,7,6,5,4) rand(9,8,7,6,5,4,3,2)}; humanindex={1 2 4 6 8}...

14 years ago | 0

Answered
Link to *.m File
You can use annotations # click on any area of your simulink model and write a name of your m-file # select this file name t...

14 years ago | 0

Answered
Acces workspace of model using sim command in parfor loop
assignin('base', 'var',value)

14 years ago | 0

| accepted

Answered
How to find points of intersections of graphs?
pas=0.01 t=-pi:pas:pi; n=length(t); a_k=[1 2 3 4]; b_k=[1 2 3 4]; for k=1:numel(a_k) f_k{k}=1-cos(a_k(k)*t-b_k(k)); [c,...

14 years ago | 1

| accepted

Answered
using unique function on column 2 and keep first col
[c,idx]=unique(G(:,2) out=G(idx,:)

14 years ago | 1

| accepted

Answered
how to pass variables from simulink to workspace,when simulink has been paused from MATLAB Script
Use set_param('Yourmodel','Simulationcommand','start') and your data will be saved to workspace

14 years ago | 2

Answered
while true vs. for i= 1:Inf
k=0; while rand<0.8 k=k+1; end The while loop will run until a condition rand < 0.8 is false, we don't know when it oc...

14 years ago | 0

Answered
Please help me about differential equations
try *lsim* function, with *tf* function

14 years ago | 0

Answered
Using "find" for finding decimal values
Try idx = find(abs(X(:,1 )-17.9203)<eps)

14 years ago | 0

Answered
transformation between different time representations
out=datenum(date) Also look at |datestr|, |datevec|

14 years ago | 0

Answered
if statement didn't executed in a loop
Are you sur the condition |if isequal(time(i),off_tt)| is true? I tested your code, the condition is true only for |i=80|...

14 years ago | 0

Answered
what is the syntaxis for numerical solvers?
sol=solve('sin(x) = y^2 - 1', 'cos(x) = y') %or sol=solve('sin(x) -y^2 + 1', 'cos(x) - y')

14 years ago | 0

Answered
detecting TRUE elements of a cell array
y={[true; false] false; false] [false; true] [true; false] false; true] [false; false] true false false ...

14 years ago | 0

| accepted

Answered
a for loop question
xx=rand(5,5,5,3); [n1,n2,n3,n4]=size(xx); X=zeros(n1,n2,n4); for k=1:n4 X(:,:,k)=0; for l=1:n3 X(:,:,k)=X(...

14 years ago | 0

Answered
'How to' Matrix
A=[0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1] for k=5:length(A) if A(k) b=A(k-4:k-1); A(k-4)=1 A(k...

14 years ago | 0

Answered
repeat a matrix in defined manner
A=[1 2 3;4 5 6;4 5 6]; m=4 B=cell2mat(arrayfun(@(x) x*ones(1,m),A,'un',0))

14 years ago | 0

| accepted

Load more