Suspensa Vix Via Fit

Answered

Storing the generated matrices from a for loop into cell arrays and access them later to multiply them altogether

No cell array required: >> x = [2,5,23]; >> A = [9,8;7,6]; >> [n,n] = size(A); >> M = 1; >> for k=numel(x):-1:1; M = M*(A-x...

Storing the generated matrices from a for loop into cell arrays and access them later to multiply them altogether

No cell array required: >> x = [2,5,23]; >> A = [9,8;7,6]; >> [n,n] = size(A); >> M = 1; >> for k=numel(x):-1:1; M = M*(A-x...

1 day ago | 0

Answered

Example got removed from the mathworks website

Unfortunately the Wayback Machine did not seem to have a copy of it, but it was still available in Google Cache, so I saved you ...

Example got removed from the mathworks website

Unfortunately the Wayback Machine did not seem to have a copy of it, but it was still available in Google Cache, so I saved you ...

2 days ago | 1

| accepted

Answered

Substitute string to double

>> A = {'0+1/R1','0-1/R1','1';'0-1/R1','0+1/R1+1/R2','0';'1','0','0'}; >> A = strrep(A,'R1','1000'); >> A = strrep(A,'R2','100...

Substitute string to double

>> A = {'0+1/R1','0-1/R1','1';'0-1/R1','0+1/R1+1/R2','0';'1','0','0'}; >> A = strrep(A,'R1','1000'); >> A = strrep(A,'R2','100...

2 days ago | 0

Answered

i want to write a code where equation is y=x*x. if y=100 what is the value of x?

>> f = @(x) x.^2 - 100; >> x = fzero(f,pi) x = 10

i want to write a code where equation is y=x*x. if y=100 what is the value of x?

>> f = @(x) x.^2 - 100; >> x = fzero(f,pi) x = 10

2 days ago | 0

| accepted

Answered

delete column from matrix

Where M is your matrix: M = M(:,24:24:end)

delete column from matrix

Where M is your matrix: M = M(:,24:24:end)

3 days ago | 0

| accepted

Answered

How can I differentiate between powermod(a,b,c) and mod(a^b,c)

>> 104^45 ans = 5.8412e+90 is well above flintmax, so it is very unlikely to exactly represent the integer that you think ...

How can I differentiate between powermod(a,b,c) and mod(a^b,c)

>> 104^45 ans = 5.8412e+90 is well above flintmax, so it is very unlikely to exactly represent the integer that you think ...

3 days ago | 0

Answered

matrix creation from a loop

The simplest and most efficient solution is to just create one matrix: lat = zeros(6964,60) which you can then trivially acces...

matrix creation from a loop

The simplest and most efficient solution is to just create one matrix: lat = zeros(6964,60) which you can then trivially acces...

3 days ago | 1

Answered

How can I index a 3D array like A(n,m,:) and get the result as a 1D array?

B = reshape(A(2,3,:),1,[])

How can I index a 3D array like A(n,m,:) and get the result as a 1D array?

B = reshape(A(2,3,:),1,[])

3 days ago | 0

| accepted

Answered

How to attribute a letter to unique combinaisons

There does not seem to be a convenient way to apply a function to table groups that does not also accumulate the results (e.g. l...

How to attribute a letter to unique combinaisons

There does not seem to be a convenient way to apply a function to table groups that does not also accumulate the results (e.g. l...

3 days ago | 0

| accepted

Answered

How can I pass a anonymous function as an output to another function?

"Looks likes I am not allowed to do that . I would like to know how this can be achieved" Your attempted code has several bugs ...

How can I pass a anonymous function as an output to another function?

"Looks likes I am not allowed to do that . I would like to know how this can be achieved" Your attempted code has several bugs ...

3 days ago | 0

| accepted

Answered

image a set of matrix variables after loading them in

Do not use load. Assign the imported data to an array, e.g.: theFiles(k).data = readmatrix(fullFileName); Now all of your impo...

image a set of matrix variables after loading them in

Do not use load. Assign the imported data to an array, e.g.: theFiles(k).data = readmatrix(fullFileName); Now all of your impo...

4 days ago | 1

| accepted

Answered

adding and subtracting elements in the same row in an nested for loop

"My assumption is that I have to do this using a nested for loop." Using array operations would be a much better use of MATLAB,...

adding and subtracting elements in the same row in an nested for loop

"My assumption is that I have to do this using a nested for loop." Using array operations would be a much better use of MATLAB,...

4 days ago | 0

| accepted

Answered

How can I sort a matrix to match another matrix?

>> [~,idx] = sort(B); >> [~,idx(idx)] = sort(A(:,2)); >> A = A(idx,:) A = 11 1 21 2 12 1 31 3 ...

How can I sort a matrix to match another matrix?

>> [~,idx] = sort(B); >> [~,idx(idx)] = sort(A(:,2)); >> A = A(idx,:) A = 11 1 21 2 12 1 31 3 ...

4 days ago | 1

| accepted

Answered

Maximization of a Function

The syntax .. = -@(..) is not valid for multiple reasons: the output of @ is a function handle. Arithmetic operations are no...

Maximization of a Function

The syntax .. = -@(..) is not valid for multiple reasons: the output of @ is a function handle. Arithmetic operations are no...

4 days ago | 1

Answered

How can I make multiple vectors the same length?

Because each of the input columns has their own domain, you will have to loop over the columns and interpolate each column separ...

How can I make multiple vectors the same length?

Because each of the input columns has their own domain, you will have to loop over the columns and interpolate each column separ...

4 days ago | 1

| accepted

Answered

How do I read multiple float values in different columns from a txt-File with headers?

You can simply use any of the high-level file importing commands that your version of MATLAB supports, e.g. readtable, readmatri...

How do I read multiple float values in different columns from a txt-File with headers?

You can simply use any of the high-level file importing commands that your version of MATLAB supports, e.g. readtable, readmatri...

5 days ago | 1

| accepted

Answered

Finding specific number of characters in vector

>> c = 'aryzbuk'; >> nnz(c~='b' & c~='r') ans = 5

Finding specific number of characters in vector

>> c = 'aryzbuk'; >> nnz(c~='b' & c~='r') ans = 5

5 days ago | 0

Answered

how to store the matrix value in cell array?

If C is a matrix, then you need to use curly braces to access the contents of the cell array T3: T3 = cell(1,10); for k1 = 1:n...

how to store the matrix value in cell array?

If C is a matrix, then you need to use curly braces to access the contents of the cell array T3: T3 = cell(1,10); for k1 = 1:n...

5 days ago | 0

| accepted

Answered

How to transmit variables in problem structure

You need to parameterize the function: https://www.mathworks.com/help/matlab/math/parameterizing-functions.html For example us...

How to transmit variables in problem structure

You need to parameterize the function: https://www.mathworks.com/help/matlab/math/parameterizing-functions.html For example us...

6 days ago | 0

| accepted

Answered

from a column in a table, get row indices where value changes

The trick is to use diff, e.g. with the example data from your question: >> Y = [0;1;1;1;0;0;0;1;1;1;0;0]; >> D = diff([0;Y;0]...

from a column in a table, get row indices where value changes

The trick is to use diff, e.g. with the example data from your question: >> Y = [0;1;1;1;0;0;0;1;1;1;0;0]; >> D = diff([0;Y;0]...

6 days ago | 1

| accepted

Answered

How to use do matrix operations without using symbols

Your approach makes this task complex and inefficient. In particular: Numbering variables like that is a sign that you are doin...

How to use do matrix operations without using symbols

Your approach makes this task complex and inefficient. In particular: Numbering variables like that is a sign that you are doin...

6 days ago | 1

| accepted

Answered

Converting a text document to a CSV

str = fileread('temp2.txt'); spl = regexp(str,'[\n\r]+','split'); spl = regexp(spl,'\s*\.\s*','split'); spl = vertcat(spl{:})...

Converting a text document to a CSV

str = fileread('temp2.txt'); spl = regexp(str,'[\n\r]+','split'); spl = regexp(spl,'\s*\.\s*','split'); spl = vertcat(spl{:})...

8 days ago | 0

Answered

How to use While loop

You need to keep the running total and the current value of y separate, e.g.: y = 1.1; t = y; c = 1; while t<1e5 c = c+...

How to use While loop

You need to keep the running total and the current value of y separate, e.g.: y = 1.1; t = y; c = 1; while t<1e5 c = c+...

9 days ago | 0

| accepted

Answered

Convert rows an columns of 4D matrix into 2d matrix with rows and columns as index Ai_j

You will get an error because plot accepts matrices only (i.e. 3rd and higher dimensions must be scalar), but apparently you are...

Convert rows an columns of 4D matrix into 2d matrix with rows and columns as index Ai_j

You will get an error because plot accepts matrices only (i.e. 3rd and higher dimensions must be scalar), but apparently you are...

9 days ago | 0

| accepted

Answered

Matrix dimensions must agree error

Wrap each input with str2double, e.g.: Temp_Coke = str2double(input('What is the current temperature of the Coke (deg F)? ', 's...

Matrix dimensions must agree error

Wrap each input with str2double, e.g.: Temp_Coke = str2double(input('What is the current temperature of the Coke (deg F)? ', 's...

9 days ago | 0

| accepted

Answered

Generating matrix from another array

>> E3 = [2,1,0,4,25,19,2,2,3,3,4,5,6,7,8,7,19]; >> X = diag(cumsum(bsxfun(@eq,E3,E3(:)),1)); >> C = arrayfun(@(n)E3(X==n),1:ma...

Generating matrix from another array

>> E3 = [2,1,0,4,25,19,2,2,3,3,4,5,6,7,8,7,19]; >> X = diag(cumsum(bsxfun(@eq,E3,E3(:)),1)); >> C = arrayfun(@(n)E3(X==n),1:ma...

10 days ago | 0

| accepted

Answered

recursive function to calculate Max number.

Urmish Haribhakti's general approach is quite good, with a few small changes it will work correctly: function x = recmax(v) if...

recursive function to calculate Max number.

Urmish Haribhakti's general approach is quite good, with a few small changes it will work correctly: function x = recmax(v) if...

10 days ago | 2

| accepted

Answered

Invalid file identifier. Use fopen to generate a valid file identifier.

You need to use the directory information in two locations: both with dir and with fopen, e.g.: vec_dir = 'Z:\Flotation_chamber...

Invalid file identifier. Use fopen to generate a valid file identifier.

You need to use the directory information in two locations: both with dir and with fopen, e.g.: vec_dir = 'Z:\Flotation_chamber...

12 days ago | 0

Answered

storing value in a variable

It looks like you are trying to declare a variable type. MATLAB does not have variable type declarations. This is what your MAT...

storing value in a variable

It looks like you are trying to declare a variable type. MATLAB does not have variable type declarations. This is what your MAT...

13 days ago | 3

| accepted