Answered
discrete-time rectangular functions
You should initialize rect_n1 to zeros if you're going to set the places where it's 1, and indexing in MATLAB starts with 1, so:...

4 years ago | 0

Answered
I need help debugging a code. Please help me.
Make a variable (I call it is_best) that stores the information about whether each stock is among the best stocks. (I've made it...

4 years ago | 0

| accepted

Answered
How to remove a certain amount of repeating elements from an array
Maybe this: given = [2 2 2 3 5 6]; input = [2 2]; nG = numel(given); nI = numel(input); i = nG-nI+1; while i > 0 if...

4 years ago | 0

Answered
How to convert each equation calculations into FOR Loop form
Eff_Ratio_17 = 1-(p.^AdK2-1)./(AdK2*(p-1)*(17^(AdK2-1))) Eff_Ratio_19 = 1-(p.^AdK2-1)./(AdK2*(p-1)*(19^(AdK2-1))) Eff_Ratio_21...

4 years ago | 0

Answered
split and sum every n columns
% a matrix: M = reshape(1:8*630,8,630) % split it up: make a 3d matrix with size 7 in the third dimension: M = reshape(M,[8 9...

4 years ago | 1

| accepted

Answered
save loop data only if 'if statement' is true
Note that if i gets set to the empty array [] somehow (e.g., in a script called from the loop), we get the error: Teapot_names ...

4 years ago | 0

Answered
Issue with Matrix Dimensions
The error I run into first is on this line: om(i,N)=u(i:N-1)/h; When i == 2, you have om(2,11) = u(2:10)/0.1; Just like the...

4 years ago | 0

Answered
Converting table within Cell arrays to matric in Matlab
You don't state how, in each cell of your wantedcell, you want to combine 30 tables with 365 rows each into one table with 365 r...

4 years ago | 1

| accepted

Answered
How to reduce the line of the codes in the code given!
files = { ... 'F:\3-PIV_Experimental_Data\Outlet_110\ABCD_DesignPoint\Profile_Plot\Sheet_D\LSD_DataoverDistance.6vr3i20t.00...

4 years ago | 1

| accepted

Answered
Saving figures in loop
They seem to be different to me (note the different y-limits) for m = 1:10 rho = 1 + m; % params chi = 1; ...

4 years ago | 0

| accepted

Answered
Editing text file to reformat the data in the text file
Something like this might work: data = cell(0,8); fid = fopen('carelton2_obs.txt'); while true line = fgetl(fid); i...

4 years ago | 0

Answered
frequency of 1, 2, 3rd most occurring number
Maybe this will work ranks = randi([1 27],27,792,'double'); % create array for a = zeros(1,27); % initialize vector for i = ...

4 years ago | 0

| accepted

Answered
How one can delete tab in figure?
clear deletes variables from a workspace. To delete graphics objects (including uitabs) you can use delete. f = figure; tabgp ...

4 years ago | 0

| accepted

Answered
Rename all the fields and subfields of a struct
You can write a little recursive function to do the field renaming: % set up a struct array: s = repmat(struct( ... 'pref...

4 years ago | 0

| accepted

Answered
plotting two data sets with different number of data point against one time series x axis
% generate some random data for demonstration: % second data: data_1 = randn(86400,1)+(1:86400).'/40000; % minute data: data...

4 years ago | 0

Answered
insert zero into the column in the array
Here is my best guess at what you're asking for: load('matlab.mat'); new_A = zeros(100,3); new_A(:,1) = 2; new_A(:,3) = 1:...

4 years ago | 0

| accepted

Answered
Delete the same numbers appeared in different rows
This will work (as long as any number repeated more than once in a single row should also be counted as a duplicate): a = [5 14...

4 years ago | 2

Answered
Matrix elements to pixel colors
I = randi(2,3000,3000)-1; my_image = imshow(I); get(my_image)

4 years ago | 1

Answered
how to create continues plot with respective time?
plot(t,angular_disp);

4 years ago | 0

Answered
Renaming .txt file names to more user-friendly and consistent style
Here is an approach you can use that assumes all files are in the current working directory, renaming them while keeping them in...

4 years ago | 0

| accepted

Answered
Minimum value within contour
You can use the information in c along with inpolygon() and logical indexing in Z to do it: [X,Y,Z] = peaks(100); figure(1),ho...

4 years ago | 1

| accepted

Answered
How would I transform a 5-dimensional vector into a 3-dimensional vector?
How you would do it depends on how you want it to work. For instance, if your 5-dimensional matrix contains two singleton (i.e....

4 years ago | 1

Answered
How to create nested loop?
A demonstration of nested for loops in MATLAB: A = magic(5); disp(A); [m,n] = size(A); for ii = 1:m for jj = 1:n ...

4 years ago | 1

| accepted

Answered
Histogram wrong Classes help
% random integers between 0 and 4; 100 rows by 8 columns data = randi(5,100,8)-1; % replace the zeros in columns 1 and 3 with ...

4 years ago | 1

| accepted

Answered
How to plot multiple lines from a for loop iteration?
Maybe this? R = 27.1; rho = 0.002036; omega = 27.01; T = 16000; A = pi.*R.^2; C_t = T ./ (rho.*A.*(omega.*R).^2); l...

4 years ago | 1

| accepted

Answered
Wrapping indexing of matrix for sum function
b = 10; d = 5; a = (1:b).'+10*(1:d) position = [1 1]; r = mod(position(1)+[-1:1]-1,b)+1; c = mod(position(2)+[-1:1]-1,d)+1;...

4 years ago | 0

Answered
Creating for loop for random matrixes .
You are getting that error because this line: A(n) = b(n)*A; attempts to assign the mxm matrix b(n)*A to A(n), which is a sing...

4 years ago | 2

Answered
Can a table returned from a function be accessed through indexing immediately?
You can do it in-line with subsref() and substruct(): subsref(tbl(),substruct('()',{':',1})) function t = tbl() t = table...

4 years ago | 0

| accepted

Answered
Average number of y for y=f(x) where there are several y values for the same x
% creating some x and y to replicate your situation, as I understand it: x = repelem([1 2 3 4],1,5); y = randn(size(x))+repele...

4 years ago | 0

| accepted

Answered
How to fill a matrix of known size with data from a row vector
A = randn(1,171072000) B = reshape(A,[],66)

4 years ago | 1

Load more