Beantwortet
Extract numbers from an integer
N = 123411; noOfOnes = nnz((dec2base(N,10) - '0')==1);

fast 9 Jahre vor | 0

Beantwortet
Intersecting a curve and a line
There is a FEX submission called curveintersections, find it on the below link: <http://de.mathworks.com/matlabcentral/fileex...

fast 9 Jahre vor | 0

Beantwortet
Export variables of for loop into an excel sheet
You probably want to store your loop iterations in an array. A = zeros(1,10); %pre-allocate for k=1:size(A,2) %use A's si...

fast 9 Jahre vor | 0

Beantwortet
How to set a column element from a text array in uitable GUI
Put all your table data in a cell array and then update them, not just one column. data = {'John',12;'Kevin',46;'Steffi,23};...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
How can Write a function that combines two lists by alternatingly taking elements, e.g. [23,11,70], [1,2,3] → [23,1,11,2,70,3].
No need to use a loop, A = [1 2 3 4 5]; >> B = 10*A; >> C = zeros(size([A B])); >> C(1:2:end) = A; >> C(2:2:end...

fast 9 Jahre vor | 0

Beantwortet
how can I add add sec, min and hours to time?
Use duration maybe, <https://www.mathworks.com/help/matlab/ref/duration.html> >> t1 = duration([07 0 0]) t1 = ...

fast 9 Jahre vor | 1

Beantwortet
How can I write a script to calculate conditional probability from a user created 2 way table
Maybe something like this? r = input(['Please enter the choice of row for conditional probabilty (between 1 to ' num2str(nu...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
how to substitute a variable in function
You need to learn about how matlab workspaces work. <https://www.mathworks.com/help/matlab/matlab_prog/base-and-function-work...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
How would i make the for loop stop calculating when it calculates F <= 0? I want the for loop to stop writing. values in F when it hits 0 or less. I have tried "break", but can not seem to get it to work.
You should simply check F(k), inside your loop, for k = 3:n r = rand(1); if r > terskelverdi F(k) = F(k-...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
Setting up vector function
c = -k(2:end); %EDITED d = k+[k(2:end);0]; e = c; in case, k is row vector, c = -k(2:end); %EDITED d = k+[k(2:e...

fast 9 Jahre vor | 2

Beantwortet
read number put them in array, remove line , and store them in new file?
Do it with dlmread and dlmwrite, <https://www.mathworks.com/help/matlab/ref/dlmread.html> <https://www.mathworks.com/help/...

fast 9 Jahre vor | 1

| akzeptiert

Beantwortet
how to sort this looping ?
Rik is right, logical indexing will make it lot simpler and faster, wmin = 0.4; wmax = 1.2; it= 1:1000; then pre-all...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
How to make a character array from loop output?
store them in a cell array, seq = cell(1,9); for m = 1:9 k(m) = randi([4,6],1); seq{m} = randseq(k(m) ,'Alphabet...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
Search array for largest value of the desired format
Something like, A = [1 2 1000 3 4 2000 4 3 3000]; B = (1:10)*1000; res = nnz(ismember(A,B)); and if there are more t...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
Dimensional problem in for loop.
*EDITED* First you should make sure if loop is required at all in the first place, if yes then I would suggest linear indexin...

fast 9 Jahre vor | 1

| akzeptiert

Beantwortet
Writing a script to create a table based on user input with row names and columns
Do it like this, row = input('Enter number of rows: '); col = input('Enter number of columns: '); A = zeros(row,col);...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
How can I get the sum of rows and columns of a table and add them to the table?
After you get the row and col values from the user, pre-allocate it by, A = zeros(row+1,col+1); I say "+1" because that'S...

fast 9 Jahre vor | 1

| akzeptiert

Beantwortet
Storing vectors for different time steps in same variable name
Why don't you use a matrix? Let's say you have 10 timesteps (1 to 10), ts = 1:10; so now you'll need to track A's chan...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
How to load specific files according to vector values?
Something like this? for k = 1:10 data = load([num2str(ii(k)) '.mat']); dataStruct(k).file=data.Cycle; end

fast 9 Jahre vor | 0

Beantwortet
How to reshape data?
If you're using 2016b or later, please use a timetable. Then you can simply call retime to make monthly averages, TT_monthly...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
comparing two matrix of different size
ismember(A,B)

fast 9 Jahre vor | 1

Beantwortet
Finding the values right after and right before some values in a matrix
res = find(V>A(1,1) & V<A(2,1)) for all elements, res = arrayfun(@(x,y) find(V>x & V<y), A(1:end-1,1), A(2:end,1),'uni',...

fast 9 Jahre vor | 0

Beantwortet
how to include n = 1:25; power = 1:4:100; cg = 1:6:150; in single expression using for loop
Do you really need a for loop? Check this, n = 1:25; power = 1:4:100; cg = 1:6:150; b=1; noise = rand(size(...

fast 9 Jahre vor | 0

Beantwortet
How to extract all the rows which match an specific string column
Use readtable to import your data, T = readtable('DatosEstructurales_C&S.txt'); if you don't have column names included ...

fast 9 Jahre vor | 4

Beantwortet
If the input is 3 we want the output to be 1 2 1
Shouldn't it be just, >> n = 7; >> weights = [1:ceil(n/2) floor(n/2):-1:1] weights = 1 2 3 4 3 2 1

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
how can I add a value to a particular cell in an array.
if A is your array, >> A = [3,2,4,5;3,2,6,4;2,5,8,5] A = 3 2 4 5 3 2 6 4 2 5 8 5...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
How can variables in workspace be used in Simulink function
One idea is to take it as an input to your function block and use the "constant block". Your function could look like, ...

fast 9 Jahre vor | 0

Beantwortet
Take date month year from serial date numbers data
if you have something like, >> dt = datetime([2017 11 06 08 00 00]) dt = datetime 2017-11-06 ...

fast 9 Jahre vor | 0

Beantwortet
How to use color code say [0.1 0.5 0.6] in patch and fill command?
remove the quotes fill (x,y, [0.5 0.3 0.6]); you need to pass a 3x1 vector, not a string.

fast 9 Jahre vor | 1

Beantwortet
How to export mulitple 1xN row matrix into the csv
Just create a table and use write table, t = array2table([A.', B.']); writetable(t,filename); or concatenate them and u...

fast 9 Jahre vor | 0

Mehr laden