Answered
Zeroing matrix elements outside of a certain range.
A simple approach via indexing - data = [1;2;3;4;5].*ones(5,2).*[0.5,0.4] out = [data(1:4,1) data(2:5,2)]

2 years ago | 0

Answered
Algorythm for Average of excel data
data = readtable('S1IA.csv') %define bins to distribute bins in idx = 0:0.5:0.5*ceil(max(data.Time)/0.5); %Get the mean of ...

2 years ago | 0

| accepted

Answered
Converting entries from array to double from an entire column in a matrix for plotting
Change the options for reading the data via detectImportOptions and use column numbers to plot - opts = detectImportOptions('t...

2 years ago | 0

| accepted

Answered
文字列から指定数だけ削除
A = ["aaa 01" "bbb 02" "aaa 02" "bbb 03" "ccc 04"] %Number of characters from end to delete n = 3; B = extractBefore(A,...

2 years ago | 0

| accepted

Answered
Convert Julian Date + Time in GMT to calendar day + Time in EST
Note that I have changed the inputs YEAR and JDDD to numeric values as they are easier to work with - I changed the name to all...

2 years ago | 3

Answered
Extracting a variable from a series of files contained inside a folder
Refer to this documentation page for importing and exporting multiple files - https://in.mathworks.com/help/matlab/import_export...

2 years ago | 0

Answered
How to make subplots bigger and title in one line?
Using tiledlayout here seems to be a better option, as it gives you a better control over the spacing and padding. Also, while ...

2 years ago | 0

| accepted

Answered
Poissons Equation with Point source
You can use inpolygon to see if the origin is inside the triangle or not and polyarea to calculate the area of the triangle - ...

2 years ago | 0

Answered
How to group discontinuous numbers
load('Risk_values.mat'); whos idx = cumsum([1;diff(mediumRiskXValues)~=1]) out = accumarray(idx, mediumRiskXValues, [], @(x...

2 years ago | 1

| accepted

Answered
Why do I get an error "Matrix dimensions must agree."
Why are you using a for loop for a task that is not changing with iterations? "Why do I get an error "Matrix dimensions must ...

2 years ago | 1

Answered
how to do a legend with text, variables, and Greek symbols in it?
You can use the symbols as provided in the list here for the default interpreter (i.e. tex) - https://in.mathworks.com/help/matl...

2 years ago | 0

| accepted

Answered
fopen and fget reading lines from a text
You need to use the file ID as input to fgetl - fid = fopen('test.txt'); %lines to read num = 3; %Preallocate a cell ar...

2 years ago | 1

| accepted

Answered
Using parfor to evaluate integrations
See - Array vs Matrix Operations xmin = -2; xmax = 1; ymin = 1; ymax = 3; dx = 0.001; dy = dx; xs = xmin:dx:xmax; Nx = ...

2 years ago | 2

| accepted

Answered
How do you get up to first n characters in a string?
A simple approach using extractBetween - s_arr = ["a";"ab";"abc";"abcd";"abcde";"abcdef";"xyzxyzxyz"] pos = 4; % pos = no. o...

2 years ago | 3

Answered
How to set both yticks(left and right) in decimal values not exponential or scientific??
Use get on the axes handle to see its structure - You will find that the YAxis is stored as 2x1 Numeric Ruler (1 for each side)....

2 years ago | 0

| accepted

Answered
index problem while sort
"ind=[2,1] is coming which is wrong." It is correct. The input to sort() only has 2 elements, so the expectation to get [3 1]...

2 years ago | 1

| accepted

Answered
how to delete multiple cells at once?
First, concatenate the data to get it in a numeric array. See - horzcat As you are dealing with floating point numbers, compare...

2 years ago | 0

Answered
Filtering the common rows between two matrices
Try this - A = [1 2 3; 4 5 6; 7 8 9]; B = [1 2 3 90; 3 1 2 88; 4 5 6 17; 6 5 4 19; 7 8 9 12; 15 18 22 20]; %sort each ro...

2 years ago | 0

Answered
Syntax problem in creating a function which takes a vector as an argument
Use element-wise power - power, .^ and define the expression as an anonymous function - r_1 = 0.84 - 0.29i; r_2 = 0.84 + 0.29i...

2 years ago | 0

| accepted

Answered
How to apply for loop in case of product of function inside double summation?
That is simply the sum of product of pairs in the given index range for a and b, thus P can be defined like this - P = 1-sum((...

2 years ago | 0

Answered
partfrac() function returning same expression
It gives the same expression as the output because the denominator can not be decomposed with the default factor format i.e. 'ra...

2 years ago | 1

Answered
Trying to extract the rows from a matrix where the values from the first two columns match the values from another matrix
%Sample data for example y1 = magic(5) y2 = y1; y2(randi(25,1,5)) = 0 %Comparison idx = all(y1(:,1:2)==y2(:,1:2), 2) out =...

2 years ago | 0

| accepted

Answered
Calculate double integrate of sin
You can simplify the expression obtained - syms theta rho n f = sin(rho)^(n + 2)*sin(theta)^(n + 1); I1 = int(f,rho,0,pi);...

2 years ago | 0

Answered
Upsampling a matrix with zero elements
%input x = [1 2 3 4; 5 6 7 8] %Upsample factor n=2; %preallocate the output matrix y = zeros(n*size(x)); %assign valu...

2 years ago | 1

Answered
Execution of script rainflow as a function is not supported, then gives the path of the rainflow.m file.
Follow instructions from this documentation page to add the directory you have mentioned to the search path of MATLAB and save i...

2 years ago | 0

Answered
How to split array into sub arrays?
a = [1 3 5 8 11 12 15 17 18 19 20 21 24 29 31 32 33 34 35 36 38 39 69].'; %bin the data into groups of 10 k = findgroups(flo...

2 years ago | 0

| accepted

Answered
Execution of script Faddeeva_w as a function is not supported:
You have defined the file "Faddeeva_w " as a script. But you are trying to call it as a function i.e. by providing an input (as...

2 years ago | 0

Answered
incorrect reading of a txt file
I am not sure what the expected output is supposed to be, but you can use readtable - in = readtable('test.txt','DecimalSepara...

2 years ago | 0

| accepted

Answered
Problems using plot3
As I have mentioned earlier in my answer to one of your questions, do not use the deprecated xlsread function. Utilize the ro...

2 years ago | 0

| accepted

Answered
Find common rows between two matrices with different number of columns
A = [1 2 3; 4 5 6; 7 8 9]; B = [1 3 20 2; 1 2 3 55; 7 8 9 10; 88 2 1 5]; %Indices of rows in B idx = 1:size(B,1); for k=...

2 years ago | 1

| accepted

Load more