Saving a new table for every loop iteration
Don't do that. Dynamic variable creation is a bad idea and totally unnecessary. <https://www.mathworks.com/matlabcentral/answ...

2 years ago | 0

| accepted

How to check monotonity of a vector?
use diff <https://www.mathworks.com/help/matlab/ref/diff.html> along with all maybe a = 1:10; isIncreasing = all(dif...

2 years ago | 2

| accepted

How to circular shift a matrix for every 1 to 6 elements until its end?
I'm only guessing. If you want to do circshifts for blocks of columns, use mat2cell first, do the shifting and convert it back u...

2 years ago | 0

| accepted

How do you check if all the values in a vector are in another vector as many or more times?
I'd recommend using intersect since you want to handle repeating elements as well. For example, a=[1 1 3 4 4]; b=[3 3 4 7]...

2 years ago | 0

How to plot more than 1 curves in one graph.
if they are in columns of excel, read it as a matrix (for a all-numeric matrix), data = xlsread(filename); now let's say ...

2 years ago | 0

If i have a graph that levels off, how can i find the first x value this occurs at, on matlab?
It depends on how you've stored your data. Let's you have them in a matrix, data = [(1:10)' zeros(10,1)]; data(5,2) = 10; ...

2 years ago | 0

How to accept only numbers in this case?
use uieditfield <https://www.mathworks.com/help/matlab/ref/uieditfield.html> fig = uifigure; edt = uieditfield(fig,'num...

2 years ago | 1

How can i specify which subplot that i want to plot on it?
use axis handles, ax1 = subplot(2,1,1); something ax2 = subplot(2,1,2); something now again go back to ax1 ...

2 years ago | 0

| accepted

how i do loop over column?
If you want to do time-based calculation with your data, for example, weekly average or something I'd highly recommend using tim...

2 years ago | 0

| accepted

Inefficient code - simple counter
I suppose your condition is something like checking the range of the specific element. Depending on what range they are in you w...

2 years ago | 0

| accepted

two for Nested Loops
An example with timetable, *EDITED* %import data data = readtable('actual data.txt'); %create a proper datetime co...

2 years ago | 0

Generic index select, without loops
V1=[45 23 26 17 29]; V2=[3 5] ; V3 = V1(~ismember(V1,V1(V2))) V3 = 45 23 17

2 years ago | 0

| accepted

How do I extract data from multiple matrices with double variable?
Oh no! Don't do that. When you can store all your data in *one* variable, why would you prefer a complex way (creating multiple ...

2 years ago | 1

| accepted

Split array into sub arrays
Or use mat2cell, res = mat2cell([x y z].',3,diff([0 find(data) numel(data)])) you get the result in a cell array, each ce...

2 years ago | 1

| accepted

Multiplying matrices and vectors in loop
_they are all 3 x 3..._ No, they are not. Check the output for the following size(CA) size(CF) and the other matrice...

2 years ago | 0

| accepted

How to check if several variables are not equal ?
use isequal. It checks all the inputs are equal and if yes, it returns 1. Use |~| if you want only the else case. if isequal...

2 years ago | 0

How can I set the numbers of decimals (precision) of the solution of fminunc?
Use the StepTolerance option, options = optimoptions(@fminunc,'StepTolerance',0.01); <https://www.mathworks.com/help/opti...

2 years ago | 0

Determine averages for duplicate values
use a table and then varfun with grouping variable as your station name, T = cell2table(C,'v',{'stationName','channelName',r...

2 years ago | 0

| accepted

Copy of multiple equal size arrays into one big array using loop
Use counter variable on the third dimension if your matrix is 2D already, for example, arr(:,:,counterVar) or a cell arra...

2 years ago | 0

How to Horizontally concatenate the values of a matrices present inside a cell array using loops?
if C is your cell array, x = cellfun(@(x)reshape(x,size(x,1),[]),C,'uni',0)

2 years ago | 0

| accepted

proof if value is greatest of a range of Values
Yes, you could do that but I'm unsure if you'd really need a for-loop. If you could explain your real intentions, the actual sol...

2 years ago | 0

how to combain matrix with vector
Something like this? a = [9 8 7; 6 5 4]; v = [1 2 3 4 5]; sz = size(a); a = [a inf(sz(1),size(v,2)-sz(2));v]

2 years ago | 1

How to call the rows of a matrix without the for loop
Probably convert them to cell array and then the use of comma-separated lists, B = num2cell(A,2) and then your_progra...

2 years ago | 0

| accepted

What can I write in a MATLAB function block in Simulink?
_If s is a vector, I will just count the number of negative entries, and then shift the y by this amount_ Shouldn't you be si...

2 years ago | 1

How to find out mean within a loop?
Store the result from each iteration and then calculate mean outside the loop. Capacitance1 = zeros(1,Number_of_measurements...

2 years ago | 1

| accepted

for loop only shows value of last iteration.
You're overwriting all your variables inside the loop so you'd only see the result of the last iteration. You'd need to use arra...

2 years ago | 0

how to extract corresponding file name from recognized index
Your code snippets are quite unclear but if you want to index certain elements from the |dir| output, that's just like indexing ...

2 years ago | 0

| accepted

why this error occur ??Index exceeds matrix dimensions.
You can easily access those elements just by accessing thier corresponding indices but you should make sure you accessing elemen...

2 years ago | 0

| accepted

how to duplicate each cell in an array
Something like this maybe, n = 3; array1 = [1,2,5]; array2 = reshape(array1.*ones(n),1,[]) 1 1 1 ...

2 years ago | 0

| accepted