Answered
Using Dir command together with xlsread troubleshooting
Much simpler: D = 'C:\Users\erik.from\Documents\MATLAB\Event'; S = dir(fullfile(D,'*.xlsx')); for k = 1:numel(S); F = fu...

6 years ago | 0

| accepted

Answered
How do I write a script that calculates and prints all values ​​for N according to the following expressions and limits?
"How do I write a script that calculates and prints all values for N according to the following expressions and limits?" k = ...

6 years ago | 0

| accepted

Answered
How to use nested functions to build a code that compares inputs
The comparison needs to be inside the loop (not after the loop): function result = grader(funA, funB, varargin) result = true;...

6 years ago | 0

| accepted

Answered
Reading textfile using fopen and textscan
This reads your file: opt = {'Delimiter',',', 'CollectOutput',true}; [fid,msg] = fopen('test_file.txt','rt'); assert(fid>=3,m...

6 years ago | 0

| accepted

Answered
Averaging Every Element of some matrices
The simple answer is to concatenate all of your matrices into one array, and then use mean. Of course all of your matrices shoul...

6 years ago | 0

| accepted

Answered
RMS value of periodic signal - using quad/quad8 command - getting an error with 'func' command
Use a function handle, just like the quad documentation states: int_v_sq = quad(@func,a,b);

6 years ago | 0

| accepted

Answered
Imread bit depth is limited to 8 bit?
Most likely you are confusing bits per pixel with bits per color. The .BMP file header contains the bits per pixel, which is ex...

6 years ago | 0

| accepted

Answered
saveas doesn't wait until imcontrast is finished
h = imcontrast(gg); waitfor(h) Simply close the tool when you are finished, the code will then continue executing.

6 years ago | 1

| accepted

Answered
Using the value of the next step in a FOR loop over a vector
"Does anyone has a hint for me how to include the next steps of the for loop into the formula?" In MATLAB it is much better to ...

6 years ago | 1

| accepted

Answered
Loading images with their names into single arrays
One of the best approaches is to simply import the file data into the same structure that dir returns, then for each file you ha...

6 years ago | 0

| accepted

Answered
Counting occurance of exact word from string array
>> C = {'Ar* + Ar* ',' Ar+ + Ar + e '}; >> S = {'Ar';'Ar*';'Ar+';'e'}; >> rgx = strcat('(?<=\s|^)',regexptranslate('escape',...

6 years ago | 0

| accepted

Answered
Function to chop a decimal to a variable number of digits
You can use an asterisk * to refer to an input of fprintf, so in your case all you need is: fprintf("%.*f\n",x,float); and tes...

6 years ago | 0

| accepted

Answered
Getting Index in position 1 exceeds arrray bound error
A better approach is to use indexing, eg.: >> I = imread('peppers.png'); >> N = 10; >> V = 1:N; >> I(fix((end-N)/2)+V,fix((e...

6 years ago | 1

| accepted

Answered
flip the sign at zero crossing point
>> Data1 = [1,0,1,0,1,0,1,0,1,0] Data1 = 1 0 1 0 1 0 1 0 1 0 >> Data2 = Data1.*cumprod([1,diff(Data1==0)...

6 years ago | 1

| accepted

Answered
Unable to accept a vector as parameter in user defined function.
A valid function definition requires the name of the input argument/s (no square brackets like you used): function result = sin...

6 years ago | 0

Answered
How can I obtain all possible combinations of a given vector
Brute force, not particularly efficient: >> A = [1,1,1,0,0,1,1]; >> P = unique(bsxfun(@and,A,unique(perms(A),'rows')),'rows');...

6 years ago | 0

| accepted

Answered
Can't seem to understand what my mistake is (Loading .mat files)
The bug is very simple: your code refers to q_Theta_y but the variable in the mat file is named q_Theta_Y You need to use th...

6 years ago | 1

| accepted

Answered
Numeric extract from char
>> regexp('("Acb2hea" == 10)','\<\d+\>','match') ans = '10' >> regexp('("Acb2hea1" >= 15)','\<\d+\>','match') ans = ...

6 years ago | 0

| accepted

Answered
How to compute the mean of several matrices in a cell?
Just for fun, if your memory can handle it: A = mean(permute(cell2mat(reshape(M_one,1,1,3,[])),[1,2,4,3]),4) For matrices of t...

6 years ago | 0

| accepted

Answered
How to declare above type of variable in MATLAB?
"How can I declare the above type of variable before hand and fill up the numbers in loop?" n = cell(1,9); for k = 1:9 n{...

6 years ago | 0

| accepted

Answered
Return multiple results from a function in one variable
"I have a function called "ols2" that calculates 12 different values. Is there some way I can call the function program without ...

6 years ago | 0

Answered
Writing Functions that take inputs?
"When I run the code nothing happens expect the prompts asking me for data." You defined a function in a script (which is permi...

6 years ago | 1

Answered
Dot Product Doubt, don't get the result I expected.
You are using the wrong operator. You need basic matrix multiplication, not the dot product: >> q1 = [0;0;0.2]; >> q1.'*q1 an...

6 years ago | 2

| accepted

Answered
fprintf columns turning out weirdly
"Why would It print like this..." Because that is exactly what you told fprintf to do: your fprintf format string has six forma...

6 years ago | 0

| accepted

Answered
convert binary to hex
>> B = '111000111100110011111001000000111101000000000111111110001111001100111110010000001111010000000001111111100011110011001111...

6 years ago | 0

| accepted

Answered
Transposing 5x5x5 matrix
new = permute(r,[2,1,3])

6 years ago | 0

| accepted

Answered
how to clip column into vectors with the rules I set
>> [~,~,idx] = unique(floor(A(:,1)/10)); >> out = accumarray(idx,A(:,2),[],@(v){v}); >> out{1} ans = 0.3000 0.8000 ...

6 years ago | 2

Answered
Floor function with a space giving an array output
Your example uses command syntax, which is explained here: https://www.mathworks.com/help/matlab/matlab_prog/command-vs-functio...

6 years ago | 0

| accepted

Answered
How to interpret entries in documentation's left pane
"What do the entries below that represent?" They list all other page headings that are at the same level in the current Content...

6 years ago | 1

| accepted

Answered
How to use regexp to extract data?
>> tdata = {'XX__TG';'GB_TH';'BN__TH'}; >> spl = regexp(tdata,'_+','split'); >> spl = vertcat(spl{:}); >> out1 = spl(:,1) ou...

6 years ago | 0

| accepted

Load more