5.992 total contributions since 2014

Suspensa Vix Via Fit

Answered

How to change one line of code?

function y = myfun(x) y = sum(x.^2); end Or if you really only want to sum the first three elements: function y = myfun(x) ...

How to change one line of code?

function y = myfun(x) y = sum(x.^2); end Or if you really only want to sum the first three elements: function y = myfun(x) ...

ongeveer 21 uur ago | 0

| accepted

Answered

what's the meaning of a number divide column vertor?

"what's the meaning of a number divide column vertor?" The mrdivide documentation explains at the top of the page that it will ...

what's the meaning of a number divide column vertor?

"what's the meaning of a number divide column vertor?" The mrdivide documentation explains at the top of the page that it will ...

ongeveer 21 uur ago | 0

Answered

Saving and uploading data with any file name

"...on how I can fix this" That is easy: fix your save syntax. You seem to have confused high-level file importing/exporting f...

Saving and uploading data with any file name

"...on how I can fix this" That is easy: fix your save syntax. You seem to have confused high-level file importing/exporting f...

1 dag ago | 0

| accepted

Answered

Fill NaN matrix with vector of unequal sizes

CMC_RT(k).RF.GyrNorm(1:10,1) = CMC_RTT.RF.(temp{a})(k,1:10); CMC_RT(k).RF.GyrNorm(1:9,2) = CMC_RTT.RF.(temp{a})(k,11:19); The...

Fill NaN matrix with vector of unequal sizes

CMC_RT(k).RF.GyrNorm(1:10,1) = CMC_RTT.RF.(temp{a})(k,1:10); CMC_RT(k).RF.GyrNorm(1:9,2) = CMC_RTT.RF.(temp{a})(k,11:19); The...

1 dag ago | 0

| accepted

Answered

Assign values to a string in Matlab

>> X = 'abcaaabc'; >> Y = num2cell(X) Y = 'a' 'b' 'c' 'a' 'a' 'a' 'b' 'c' >> Y1 = X-97 Y1 = ...

Assign values to a string in Matlab

>> X = 'abcaaabc'; >> Y = num2cell(X) Y = 'a' 'b' 'c' 'a' 'a' 'a' 'b' 'c' >> Y1 = X-97 Y1 = ...

4 dagen ago | 0

Answered

Figures not saving as specific file type regardless of specified extension

Specifying the image file type and specfiying the file extension are two totally different things. Your title "Figures not savin...

Figures not saving as specific file type regardless of specified extension

Specifying the image file type and specfiying the file extension are two totally different things. Your title "Figures not savin...

4 dagen ago | 1

| accepted

Answered

regexprep does not exactly what I want

>> regexprep(Charge,'^[^-+]*','') ans = '-1' '+0' '+1' '-1' '+0' '+1' >> regexp(Charge,'[-+].+$','once','...

regexprep does not exactly what I want

>> regexprep(Charge,'^[^-+]*','') ans = '-1' '+0' '+1' '-1' '+0' '+1' >> regexp(Charge,'[-+].+$','once','...

4 dagen ago | 1

Answered

Values in cell array keep getting overwritten

Much simpler and much more robust: D = 'path to the main directory'; S = dir(fullfile(D,'img*')); for k = 1:numel(S) F =...

Values in cell array keep getting overwritten

Much simpler and much more robust: D = 'path to the main directory'; S = dir(fullfile(D,'img*')); for k = 1:numel(S) F =...

4 dagen ago | 0

Answered

What are variable scopes?

Consider that inside some function you define some variable, e.g.: X = 3; You might then ask yourself, now that I have defined...

What are variable scopes?

Consider that inside some function you define some variable, e.g.: X = 3; You might then ask yourself, now that I have defined...

4 dagen ago | 0

| accepted

Answered

concatenate structs and then plot a specified column

Simpler without conditional statements: D = 'path to the folder/Dati_Finali'; S = dir(fullfile(D,'*.mat')); b = 1; for k = 1...

concatenate structs and then plot a specified column

Simpler without conditional statements: D = 'path to the folder/Dati_Finali'; S = dir(fullfile(D,'*.mat')); b = 1; for k = 1...

4 dagen ago | 0

Answered

Count the values inside a cell array considering another cell array

>> Rc = vertcat(R{:}); >> Vc = vertcat(V{:}); >> X = ~cellfun('isempty',Rc) & ~cellfun('isempty',Vc); >> F = @(r,v) sum(r(2,v...

Count the values inside a cell array considering another cell array

>> Rc = vertcat(R{:}); >> Vc = vertcat(V{:}); >> X = ~cellfun('isempty',Rc) & ~cellfun('isempty',Vc); >> F = @(r,v) sum(r(2,v...

4 dagen ago | 0

| accepted

Answered

Saving the values into a mat file error

Rather than this indirect, complex, buggy, obfuscated, strongly inadvisable code: evalstring = sprintf('handles.mystructdata.%s...

Saving the values into a mat file error

Rather than this indirect, complex, buggy, obfuscated, strongly inadvisable code: evalstring = sprintf('handles.mystructdata.%s...

4 dagen ago | 0

| accepted

Answered

de2bi not working for large decimal number

"Why is that?" Because those functions use double class, and your value is well above flintmax: >> 2^53 % flintmax ans = 9.00...

de2bi not working for large decimal number

"Why is that?" Because those functions use double class, and your value is well above flintmax: >> 2^53 % flintmax ans = 9.00...

4 dagen ago | 0

| accepted

Answered

Count how many element are inside each cell af a cell array on the basis of an array

>> C = vertcat(V{:}); >> X = ~cellfun('isempty',C); >> F = @(x)sum(x(2,:)<=80); >> M = zeros(size(C)); >> M(X) = cellfun(F,C...

Count how many element are inside each cell af a cell array on the basis of an array

>> C = vertcat(V{:}); >> X = ~cellfun('isempty',C); >> F = @(x)sum(x(2,:)<=80); >> M = zeros(size(C)); >> M(X) = cellfun(F,C...

4 dagen ago | 0

| accepted

Answered

How to subtract two close numbers?

"..i don't know why it doesn't give exact zero." The decimal values 5.4 and 0.4 cannot be represented exactly using binary floa...

How to subtract two close numbers?

"..i don't know why it doesn't give exact zero." The decimal values 5.4 and 0.4 cannot be represented exactly using binary floa...

4 dagen ago | 1

| accepted

Answered

Find the intersect of two columns from different matrix but keep the corresponding cells from the same row along with the intercept values

>> A = [2,4,6,8,10;2,3,5,3,2] A = 2 4 6 8 10 2 3 5 3 2 >> B = [2,3,5,8,10;1,2,2,2,1] B = ...

Find the intersect of two columns from different matrix but keep the corresponding cells from the same row along with the intercept values

>> A = [2,4,6,8,10;2,3,5,3,2] A = 2 4 6 8 10 2 3 5 3 2 >> B = [2,3,5,8,10;1,2,2,2,1] B = ...

5 dagen ago | 0

| accepted

Answered

Alternation without for loop

>> N = min(numel(A),numel(B)); >> V = [reshape([A(1:N);B(1:N)],1,[]),A(N+1:end),B(N+1:end)] V = 1 0.5 2 0.2 3 0.4 4 ...

Alternation without for loop

>> N = min(numel(A),numel(B)); >> V = [reshape([A(1:N);B(1:N)],1,[]),A(N+1:end),B(N+1:end)] V = 1 0.5 2 0.2 3 0.4 4 ...

5 dagen ago | 1

Answered

Modify a cell array and obtain a new cell array

The problen is that you try to access a row of GGG which does not exist. You define GGG as a 1x2 cell array: GGG= {[...],[...]...

Modify a cell array and obtain a new cell array

The problen is that you try to access a row of GGG which does not exist. You define GGG as a 1x2 cell array: GGG= {[...],[...]...

5 dagen ago | 0

| accepted

Answered

Matching closest values to each other

>> [~,idx] = min(abs(bsxfun(@minus,B,A.')),[],2); >> C = [B,A(idx)] C = 39.167 39.342 39.892 39.942 40.592 4...

Matching closest values to each other

>> [~,idx] = min(abs(bsxfun(@minus,B,A.')),[],2); >> C = [B,A(idx)] C = 39.167 39.342 39.892 39.942 40.592 4...

5 dagen ago | 0

Answered

finding location of logical 1 row wise by column

[idr,~] = find(yourMatrix)

finding location of logical 1 row wise by column

[idr,~] = find(yourMatrix)

5 dagen ago | 0

| accepted

Answered

Difference between ' (single quote) vs " (double quote)?

https://www.mathworks.com/help/matlab/characters-and-strings.html In a nutshell: single quotes define a character vector with ...

Difference between ' (single quote) vs " (double quote)?

https://www.mathworks.com/help/matlab/characters-and-strings.html In a nutshell: single quotes define a character vector with ...

5 dagen ago | 0

| accepted

Answered

Array vs. Matrix Operations

What "compatible sizes" means is explained on this page: https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-siz...

Array vs. Matrix Operations

What "compatible sizes" means is explained on this page: https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-siz...

5 dagen ago | 0

| accepted

Answered

SAVE command: How to specify the variable to be saved if it is a variable inside an array. assignin has been used to create the variable from a string in an array.

save using the structure syntax: S = struct('theNameYouWant',x); save(...,'-struct','S')

SAVE command: How to specify the variable to be saved if it is a variable inside an array. assignin has been used to create the variable from a string in an array.

save using the structure syntax: S = struct('theNameYouWant',x); save(...,'-struct','S')

6 dagen ago | 0

| accepted

Answered

How to fill NaN values in 3d array using interpolation?

The simple solution is to download this: https://www.mathworks.com/matlabcentral/fileexchange/4551-inpaint_nans

How to fill NaN values in 3d array using interpolation?

The simple solution is to download this: https://www.mathworks.com/matlabcentral/fileexchange/4551-inpaint_nans

6 dagen ago | 1

| accepted

Answered

how to extract and load images and data from multiple .mat files present in a folder

https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html D = 'path to the folder where the files ar...

how to extract and load images and data from multiple .mat files present in a folder

https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html D = 'path to the folder where the files ar...

7 dagen ago | 1

Answered

creating matrix from a vector

>> v = [0,0,4,6] v = 0 0 4 6 >> n = ceil(v/2); >> w = 1:max(n); >> m = bsxfun(@times,v,bsxfun(@le,w(:),n)) m = ...

creating matrix from a vector

>> v = [0,0,4,6] v = 0 0 4 6 >> n = ceil(v/2); >> w = 1:max(n); >> m = bsxfun(@times,v,bsxfun(@le,w(:),n)) m = ...

8 dagen ago | 1

| accepted

Answered

How can I create an input row only excisting randomly only out of -1 and +1?

>> V = [-1,1]; >> X = randi(2,1,23); >> V(X) ans = -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 1 1 ...

How can I create an input row only excisting randomly only out of -1 and +1?

>> V = [-1,1]; >> X = randi(2,1,23); >> V(X) ans = -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 1 1 ...

8 dagen ago | 1

Answered

Calling Matrix that is indexed, in a for loop

The easiest approach is to use a cell array: T{1} = [1,2]; T{2} = [2,3,4]; T{3} = [3,4,5]; T{4} = [3,4,5]; T{5} = [1,5]; f...

Calling Matrix that is indexed, in a for loop

The easiest approach is to use a cell array: T{1} = [1,2]; T{2} = [2,3,4]; T{3} = [3,4,5]; T{4} = [3,4,5]; T{5} = [1,5]; f...

8 dagen ago | 0

| accepted

Answered

Question about import a .txt file into matlab

Your code has several issues, the most significant ones are: you incorrectly used the optional third input, apparently to try a...

Question about import a .txt file into matlab

Your code has several issues, the most significant ones are: you incorrectly used the optional third input, apparently to try a...

9 dagen ago | 1

| accepted