Answered

Create Plot Title of the Plotted Function

x = 0:.01:1; for i= 1:9 subplot(3,3,i) y = x.^i; plot(x, y, 'black') xlabel('x') ylabel('y') titl...

Create Plot Title of the Plotted Function

x = 0:.01:1; for i= 1:9 subplot(3,3,i) y = x.^i; plot(x, y, 'black') xlabel('x') ylabel('y') titl...

2 months ago | 1

| accepted

Answered

Saving extracted audio files in a For loop

wor_dir = 'your_directory_path' for p = 1:3 startSample = n; endSample = length(data); extractedData = data(star...

Saving extracted audio files in a For loop

wor_dir = 'your_directory_path' for p = 1:3 startSample = n; endSample = length(data); extractedData = data(star...

2 months ago | 0

| accepted

Answered

How to find and replace the content of an array

out = cellfun(@(x)datetime(x, 'Format','dd/MM/yyyy HH:mm:ss'), input_cell)

How to find and replace the content of an array

out = cellfun(@(x)datetime(x, 'Format','dd/MM/yyyy HH:mm:ss'), input_cell)

2 months ago | 0

Answered

How to sum the diagonal numbers and numbers after the diagonal of a matrix

function summa = halfsum(inp_mat) summa = zeros(2,1); % first element is sum of diagonal elements, second is sum of dia...

How to sum the diagonal numbers and numbers after the diagonal of a matrix

function summa = halfsum(inp_mat) summa = zeros(2,1); % first element is sum of diagonal elements, second is sum of dia...

2 months ago | 0

Answered

create zero column vector

zeros is the MATLAB function already, its not recommended to create again a function "createzerocolumnvector(x)", use direct com...

create zero column vector

zeros is the MATLAB function already, its not recommended to create again a function "createzerocolumnvector(x)", use direct com...

2 months ago | 0

Answered

How to combine rows of cell array into corresponding single cell

c = cellfun(@(x, y){x,y}, a,b,'UniformOutput',false)

How to combine rows of cell array into corresponding single cell

c = cellfun(@(x, y){x,y}, a,b,'UniformOutput',false)

2 months ago | 1

| accepted

Answered

Writing data to a file

fileid= fopen('data.dat','w'); fprintf(fileid, '%d\n', [1:20]'); fclose(fileid)

Writing data to a file

fileid= fopen('data.dat','w'); fprintf(fileid, '%d\n', [1:20]'); fclose(fileid)

2 months ago | 0

| accepted

Answered

for loop, multiple plots in single plot

Vi = 25; t1 = [0:0.1:86.3]; t2 = [0:0.1:13.5]; t3 = [0:0.1:13.5]; t4 = [0:0.1:6]; g = [0.58 3.7 3.71 8.87]; hPluto = Vi .*...

for loop, multiple plots in single plot

Vi = 25; t1 = [0:0.1:86.3]; t2 = [0:0.1:13.5]; t3 = [0:0.1:13.5]; t4 = [0:0.1:6]; g = [0.58 3.7 3.71 8.87]; hPluto = Vi .*...

3 months ago | 0

Answered

fprintf cell array of two classes

require = string(cell2mat(strcat(charArr,{' '}, num2str(doubArr))));

fprintf cell array of two classes

require = string(cell2mat(strcat(charArr,{' '}, num2str(doubArr))));

3 months ago | 0

Answered

fprintf handles.Value?

if handles.Value is a string fprintf(f,'%s',handles.Value); if handles.Value is a float value fprintf(f,'%3.2f',str2num(ha...

fprintf handles.Value?

if handles.Value is a string fprintf(f,'%s',handles.Value); if handles.Value is a float value fprintf(f,'%3.2f',str2num(ha...

3 months ago | 0

| accepted

Answered

How to get common sub string in cell array string?

fund_cell = regexp(cell_arr , 'A.A1', 'match'); result = [fund_cell{:}]

How to get common sub string in cell array string?

fund_cell = regexp(cell_arr , 'A.A1', 'match'); result = [fund_cell{:}]

3 months ago | 0

Answered

Binarize a metrix with some threshold

A = randi([0, 1000], 5) % dummy marix A = 392 277 317 766 646 656 46 951 795 710 171 97 ...

Binarize a metrix with some threshold

A = randi([0, 1000], 5) % dummy marix A = 392 277 317 766 646 656 46 951 795 710 171 97 ...

3 months ago | 0

Answered

if statement with vector

You are checking all values in the if conditioning, it gives pass condition if and only of all values are true, to avoid your si...

if statement with vector

You are checking all values in the if conditioning, it gives pass condition if and only of all values are true, to avoid your si...

3 months ago | 2

Answered

How to find the middle element of a square array

function middleElement = FindMiddle(squareArray) % FindMiddle: Return the element in the center of squareArray % Inputs: sq...

How to find the middle element of a square array

function middleElement = FindMiddle(squareArray) % FindMiddle: Return the element in the center of squareArray % Inputs: sq...

3 months ago | 0

Answered

Populate .csv with specific times and dates

required_times = t(hour(t)>12 & hour(t)<17) % where timings between 12 to 17 hours of the data

Populate .csv with specific times and dates

required_times = t(hour(t)>12 & hour(t)<17) % where timings between 12 to 17 hours of the data

3 months ago | 0

Answered

If statement - comparing single value to whole array

if any(B>A) % your code end

If statement - comparing single value to whole array

if any(B>A) % your code end

3 months ago | 0

Answered

Xor operation on two numbers

Since decimal to binary conversion may not produce same length of inputs to xor, we need to append 0's before the binary value ...

Xor operation on two numbers

Since decimal to binary conversion may not produce same length of inputs to xor, we need to append 0's before the binary value ...

3 months ago | 0

| accepted

Answered

Index in position 1 is invalid. Array indices must be positive integers or logical values.

Index of the array start from 1 and it must be positive integer in MATLAB. In your code for loop i = 0:366 starting from 0 that...

Index in position 1 is invalid. Array indices must be positive integers or logical values.

Index of the array start from 1 and it must be positive integer in MATLAB. In your code for loop i = 0:366 starting from 0 that...

3 months ago | 0

| accepted

Answered

How to read and arrange certain data in multiple text file?

FAM_data = readmatrix('FAM.txt'); FCC_data = readmatrix('FCC.txt'); FM2_data = readmatrix('FM2.txt');

How to read and arrange certain data in multiple text file?

FAM_data = readmatrix('FAM.txt'); FCC_data = readmatrix('FCC.txt'); FM2_data = readmatrix('FM2.txt');

3 months ago | 0

| accepted

Answered

area of a circle function file / prompt and fprintf() output

function area_circle() radius = input('Enter the radius: '); area_cir = pi.*radius.^2; disp(['Area of circle: ', num2str(area...

area of a circle function file / prompt and fprintf() output

function area_circle() radius = input('Enter the radius: '); area_cir = pi.*radius.^2; disp(['Area of circle: ', num2str(area...

3 months ago | 0

| accepted

Answered

Creating groups of 2 people from a cell array of names

n = 26; x = cellstr(char([65:65+n-1]')); % your cell data assumed rand_nums = reshape(randsample(n,n), n/2, 2); % random numbe...

Creating groups of 2 people from a cell array of names

n = 26; x = cellstr(char([65:65+n-1]')); % your cell data assumed rand_nums = reshape(randsample(n,n), n/2, 2); % random numbe...

3 months ago | 0

Answered

Multiplying an entire table by a column from another table.

t1 = table; t2 = table; % table t1 t1.a = rand(10,1); t1.b = rand(10,1); % table t2 t2.c = rand(10, 1); %processed_data ...

Multiplying an entire table by a column from another table.

t1 = table; t2 = table; % table t1 t1.a = rand(10,1); t1.b = rand(10,1); % table t2 t2.c = rand(10, 1); %processed_data ...

3 months ago | 0

Question

Validate and get exact number of characters using the regular expression

Hi all, I am using MATLAB R2016a version and working on a chacters set like str = 'ENGINE-45'; % this is okay(digits are 2 a...

3 months ago | 2 answers | 0

Answered

How to use unique function here

inn_A = [A{:}]; str_A = cellfun(@(x)num2str(x(:)'),inn_A,'UniformOutput',false); [~,idx,idx2] = unique(str_A); Result = inn_A...

How to use unique function here

inn_A = [A{:}]; str_A = cellfun(@(x)num2str(x(:)'),inn_A,'UniformOutput',false); [~,idx,idx2] = unique(str_A); Result = inn_A...

3 months ago | 0

| accepted

Answered

I want to plot the Point directly on the highest point of the graph

[MaxPower, MaxPow_loc] = max(Power); % then apply hold on; plot(MaxPow_loc,MaxPower,'or','MarkerFaceColor', 'r', 'MarkerSize'...

I want to plot the Point directly on the highest point of the graph

[MaxPower, MaxPow_loc] = max(Power); % then apply hold on; plot(MaxPow_loc,MaxPower,'or','MarkerFaceColor', 'r', 'MarkerSize'...

3 months ago | 0

| accepted

Answered

Combine two column vectors when importing data from .csv into one

f = fopen('your file name.csv', 'r') % data = textscan(f, '%s'); fclose(f); your_data = cellfun(@str2num, strrep(data{1}, ...

Combine two column vectors when importing data from .csv into one

f = fopen('your file name.csv', 'r') % data = textscan(f, '%s'); fclose(f); your_data = cellfun(@str2num, strrep(data{1}, ...

3 months ago | 0