Answered
Find a letter position within a word.
This might help you: function indexes = find_letter_positions(word,letter) indexes = zeros(1,numel(word)); for i = 1:...

8 years ago | 0

| accepted

Answered
Fourier Series in matlab with for loop
You do not need a _for loop_. If you have *Symbolic Toolbox*, the following code should do it: syms f(t) n k=5; %upper l...

8 years ago | 0

Answered
How make an equivalent function of unit delay in matlab
*Delay* block comes with its _Input Port_ choice within the mask in its *Source*. Check the attached figures.

8 years ago | 0

Answered
Store results from loop.
I believe you need to read about _for loop_ and _subscripting_. Try this: As1=510; fy=420; h = 650; d = 590; Es = 200000; ...

8 years ago | 1

Answered
loop in sum series and product
You don't need a _for loop_. If you have *Symbolic Toolbox*, you can easily calculate it as: syms t n l=3;m=6;k=3; %rand...

8 years ago | 0

Answered
Write the '+', '-' signs in front of the polynomial coefficients
Try this( *Symbolic Toolbox* is required for this code): v = fliplr([2 -3 +4 -5]); syms x; fun(x)=sym(0); for i=1:...

8 years ago | 1

| accepted

Answered
Normal distribution for a given range of numbers.
Use *rand*, instead of *randn*: x=xmin+rand(1,n)*(xmax-xmin);

8 years ago | 2

| accepted

Answered
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
The output of *vpasolve* seems to be returning _empty_ solutions. You can detect if the solutions are empty and assign an *eps* ...

8 years ago | 1

| accepted

Answered
How to flip values greater than zero in a row
Try this: A=[0 0 0 0 1 2 3 0 0 0] idx=find(A~=0); A(idx+nnz(A)-1)=fliplr(A(idx)); A(idx(1:end-1))=0

8 years ago | 0

| accepted

Answered
Why is there a blank zone at the start of my simulink simulation?
Probably in your *Scope* block, you have a parameter checked. Go to *Settings->Logging* and uncheck *Limit data points to last* ...

8 years ago | 0

| accepted

Answered
How can i add a error check to this program such that the input must only be in numbers?
Try this: x=input('choose between 1 to 3') while true value = input('Enter any value that you want to convert:','s')...

8 years ago | 1

| accepted

Answered
Solve differential Equation for certain values of variable x
Try this: syms x z(x)=diff(sin(x)-cos(x)) xVal=[2 3 4 5]; zVal=z(xVal) What you need to do is to define a symbo...

8 years ago | 0

| accepted

Answered
Is there a general formula to calculate the sum of the squares logarithms of first n natural numbers?
*Symbolic Toolbox* and its features are best for you to get what you want. For instance: syms S(n,x) m S(n,x)=symsum(log...

8 years ago | 0

Answered
Error in port widths or dimensions
It seems a simple *Reshape* block solved the issue. Hope this helps.

8 years ago | 0

| accepted

Answered
How to graph the closed-loop response of MIMO Control System?
Actually what you did to obtain closed loop forms is wrong. I suggest you to obtain them in a _for loop_ separately as follows: ...

8 years ago | 0

Answered
exchange data between blocks using Workspace in Simulink.
Actually, you can not use *From Workspace* or *To Workspace* blocks to exchange data during simulation. They are meant to be use...

8 years ago | 0

| accepted

Answered
robotics trajectory generation with simulink
I made a simple model where you reach your position target either by a *ramp* function, or a *sinusoidal* function. Open the mod...

8 years ago | 0

Answered
When to use “to workspace” block vs “outport” block
Actually, there is no certain answer for that and also, they are not intended to be used for just logging the simulation data. L...

8 years ago | 2

Answered
How to get a matrix as an output in a function?
Firstly, it does not make any sense to pass input arguments to your function and not using them in your function and since the o...

8 years ago | 2

Answered
Hi, i am facing a error in simulation using simulink. the error is shown in figure (attached) and the simulink model is also attached in zip file. please help me to remove this error and run this model. i will be very thankful for this kindness. tha
If you read the help of the block you use carefully, it wants its inputs to be given as vector or matrix, therefore *Buffer* blo...

8 years ago | 1

| accepted

Answered
Find common data between two vectors
One approach: A = [3 4 6 1 7 2 5 6 7 9 0 3 2 8]; B = [4 5 6 6 1 7 2 5 6 7 9 0 3 2 0 5 8 7]; pattern = [6 1 7 2 5 6 7 ...

8 years ago | 0

Answered
Having trouble getting function to return two values
Probably you are calling function with *one output argument*, like y = cross(lambda) or none, cross(lambda) You sh...

8 years ago | 1

| accepted

Answered
How to plot level curves of f(x,y) = 2x^2 + 5y^2. f(x,y) = c for c = 1,2,3,4,5,6
Check the output of this code: f=@(x,y) 2*x.^2 + 5*y.^2; [X,Y]=meshgrid(-2:0.001:2); z=f(X,Y); contour(X,Y,z,[1:6]...

8 years ago | 1

Answered
How do I sketch x[n] = 2e^(n.j.pi/6) +2e^(-n.j.pi/6) for 0<n<5 and 0 otherwise
Something like this? syms x(n) x(n)=piecewise(n>0 & n<5,2*exp(n*j*pi/6)+2*exp(-n*j*pi/6),0) n=0:0.001:5; plot(n,x(...

8 years ago | 0

| accepted

Answered
How to use nested for loops?
No need for nested for loops. Try this: i=1;n=5; while i<=n fprintf('%d',[1:i-1 i:-1:1]); fprintf('\n'); ...

8 years ago | 0

Answered
extractBefore function not giving correct answer.
The following code simply does what you want: seq = 'MSKAHFRQWTYVSKATYQRW'; for i=1:numel(seq) Seq{i}=seq(1:i); ...

8 years ago | 0

| accepted

Answered
How can I give initial condition as given in following equation?
Try this(requires Symbolic Toolbox): syms x(t) eq=diff(x,t)==5*x-3; initCond=x(2)==1; X(t)=dsolve(eq,initCond)

8 years ago | 0

| accepted

Answered
Plotting a second graph on an existing figure
You need something like this: R=22; L = 300; N = [1:3:45]; X = (L.*N)./(R+N); figure(1); plot(N, X); xl...

8 years ago | 0

Answered
Replacing elements of multilevel cell arrays
Usage of *cellfun* might help: idx=cellfun(@(x) isinf(x),meancalc) This will output logical array. Then, meancalc(idx...

8 years ago | 0

Answered
Reshape and rearrange elements of a matrix
B=reshape(A.',3,4).';%temp B(2:3,:)=flipud(B(2:3,:))

8 years ago | 0

Load more