Answered
The value assigned to variable 'total' might be unused
This line is not a valid Matlab syntax total += Set(i); You need to change it to: total = total + Set(i);

6 years ago | 0

| accepted

Answered
Pause button for GUI
Following your code, for example (The property 'Interruptible' of the start button must be set to 'on'): % --- Executes on bu...

6 years ago | 0

Answered
When using for loops to generate multiple graphs on the same plot, how do I update the legend also using the for loop?
You need to call legend function just one time outside the loop figure(1) hold on; names = cell(1,17); for kk = 1:17 sc...

6 years ago | 0

| accepted

Answered
Newton polynomial interpolating points, matrix too big
Try changing this line c=A\y by c=A\y'

6 years ago | 0

| accepted

Answered
Warning "Ignoring extra legend entries"
You are calling legend in each iteration of the loop. In the first 2 iterations your plots have less than 3 lines and you are ca...

6 years ago | 5

| accepted

Answered
How to make multiple dots move in matlab graph simultaneously
Changing each line object: pmax=20 % total no of dots x=0 %initialise the coordinates of each dots y=0 dt=0...

6 years ago | 1

Answered
a boundary value problem
Indexing in Matlab starts in 1, then: f(:,0) is not a valid indexing. It should be: f(:,1)

6 years ago | 0

Answered
Error message "Index exceeds matrix dimensions"
Your for loop goes from 1 to the sum of the elements of the three inputs (in your example, 30), then, when ii = 11: iM(ii); jM...

6 years ago | 0

Answered
remove cell array content matrix with condition: length of element in cell smaller than specific value
cell_A = {[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5];[11 11 11];[0 0 0;1 1 1;2 2 2;3 3 3;4 4 4;5 5 5]}; cell_A(cellfun(@size,cell_A,repmat...

6 years ago | 0

| accepted

Answered
Find Borders and their Indices
Using findpeaks function: [value,firstZeros] = findpeaks(-abs(A)); firstZeros = firstZeros(~value); [value,lastZeros] = findp...

6 years ago | 0

Answered
randomly generate point satisfying quations
If you have symbolic toolbox: syms x y eqn = x.^2+(3/2*y-sqrt(abs(x)))^2 == 3; z(x) = solve(eqn,y); xrand = rand(1,100); %So...

6 years ago | 0

| accepted

Answered
Insert blank/NaN rows in a column
Do you mean this? A = rand(288,1); A = reshape(A,[24,12]) B = reshape(1:numel(A),[24,12]) plot(B,A)

6 years ago | 0

Answered
how to plot multiple decaying exponentials in one plot.
Here two options: time = [20 50 80]; peak = [5 3 2]; decay = [2 4 6]; % Symbolic toolbox needed figure syms t X = peak....

6 years ago | 0

Answered
How to set ranges for 2 different variables in the same loop?
You don't need a loop: x = randi(100,1,100); y = randi(100,1,100); idx = ((x < 40) & (x > 15) & (y < 25) & (y > 5)); x = x(i...

6 years ago | 0

| accepted

Answered
while loop with three conditions
Changing && by ||: i=2; while (sqrt(data(i,1)^2+data(i,2)^2+data(i,3)^2) > 0.10 || sqrt(data(i+1,1)^2+data(i+1,2)^2+data(i+1,3...

6 years ago | 1

| accepted

Answered
Padding zeros at the end row of a matrix
A = [A;zeros(mod(d-mod(size(A,1),d),d),size(A,2))];

6 years ago | 1

| accepted

Answered
How to stop plotting after function hits first zero in oscillatory system?
clc,clear,close all dt = 1e-4; time = 0:dt:12e-3; hz = [50 500 1000]; haversine50 = (0.5)*(1-cosd(hz(1)*2*360*time)); zero ...

6 years ago | 1

| accepted

Answered
How to replace rows contain NaN with values from another matrix?
A(isnan(A)) = B(isnan(A))

6 years ago | 0

| accepted

Answered
filling a matrix with a loop
A = repmat([1 1 0 1 zeros(1,396)],400,1); A = cell2mat(arrayfun(@(i) circshift(A(i,:),i-1) , 1:size(A,1), 'UniformOutput',false...

7 years ago | 0

Answered
How can I creat a empty string?
% for string a = string([]); for i = 1:3 a(end+1) = "1"; end

7 years ago | 1

| accepted

Answered
How to store values matrix in cell
Try this: t = [1 2 3]; M = arrayfun(@(t) [t^2 t 1 0 0 0; 0 0 0 t^2 t 1],t,'UniformOutput',false);

7 years ago | 0

| accepted

Answered
How to pick next value from vectors based on a condition?
max(A(5:end))

7 years ago | 0

Answered
Error using title (line 21) Incorrect number of input arguments
The syntax o f function title is title(obj,txt) where variable obj must be an axes object or a legend object, but in your code...

7 years ago | 1

| accepted

Answered
How to make Structs with Symbolic Variables in Matlab
syms speed weight car.speed = speed; car.weight = weight; car.KE = 0.5*car.speed^2*car.weight;

7 years ago | 1

Answered
Want to apply two different functions on different elements of a vector.
a = 1; b = 5; odd = @(w) a*w+b*w^2; even = @(w) a*w^2+b*w; curr_w = rand(1,5); aa = arrayfun(odd,curr_w(1:2:numel(cu...

7 years ago | 0

| accepted

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
Running your code, it throws an error in this line P(k) = Pk_prev; The problem is that PK_prev is of size 2x2 and P is 1x200,...

7 years ago | 1

Answered
Simpson's-Rule
The while loop never ends because the contidion is never satisfied. The problem is that Re and fRe don't change inside the loop ...

7 years ago | 1

Answered
hi every one ,
sum(A==1) % or sum(A==2)...

7 years ago | 0

| accepted

Answered
How to sum up numbers into a cell?
If a is your cell array: b = cellfun(@sum,a)

7 years ago | 0

| accepted

Answered
Don't want my points on the boundary
Here we are: s = 2; ss = -s:s; [x,y] = meshgrid(ss); plot(x,y,'ko'); hold on; xlim([-3,3]) ylim([-3,3]) xticks(ss) ytic...

7 years ago | 1

| accepted

Load more