Answered
I'm trying to display pascals triangle but the higher numbers are messing up the formatting, any solutions?
You can specify some field widths in your fprintf calls. rows = 15; PT = zeros(rows); for c = 1:rows PT(c,1) = 1; f...

3 years ago | 1

Answered
Vectorize output of for loop, but using specific vector values
k=1.38E-23; E0= 2.72361635536024e-21 M=3; myVector = zeros(M+1,1); T = [100,300,1000,3000]; for ii = 1:numel(T) ...

3 years ago | 0

| accepted

Answered
comparision of data with logic given as input
Assuming T1, ..., T10 are scalars, T = [T1 T2 T3 T4 T5 T6 T7 T8 T9 T10]; [~,idx] = max(T); I = zeros(size(T)); I(idx) = ...

3 years ago | 0

| accepted

Answered
How to label the x axis in matlab for boxplot ?
xticklabels({'january','feb','mar'})

3 years ago | 0

| accepted

Answered
combine cell data into column
M = vertcat(C{:}); where C is your cell array; M will be your big column vector.

3 years ago | 0

| accepted

Answered
Changing numeric matrix name with the loaded file
[fn,pn] = uigetfile('*.mat','Select .mat File'); if isequal(fn,0) return % user closed dialog without selecting a file ...

3 years ago | 0

Answered
plot a graph from user input
Change this: plot(u,t) to this: plot(t,u)

3 years ago | 0

Answered
ASCII/HAMMING DECODER
It's been awhile since I studied error-correcting codes, but I believe that with this generator matrix: G = [1 0 0 0 1 1 0; ...

3 years ago | 0

| accepted

Answered
How to plot histogram using given data ?
% Value first Second third M = [ ... 10 0.67 0.66 0.70; ... 20 0.38 0.37 0.42; ... 30 0.26 0.25 0...

3 years ago | 0

| accepted

Answered
How to change a range of numbers in a matrix to a random number of a matrix?
G = reshape(1:125,[25,5]) x = setdiff(0:24, 2:25) idx = G >= 2 & G <= 25; G(idx) = x(randi(numel(x),[nnz(idx),1]))

3 years ago | 0

| accepted

Answered
Parsing this line 'Step Information: Rload=100 R1=1 (Run: 2/18)'
Here's one way: % Example line to parse line = 'Step Information: Rload=100 R1=1 (Run: 2/18)'; % Parse the line using rege...

3 years ago | 0

Answered
Appdesigner get Index and String from DropDownMenu
If you need the index and the string, then the way you're doing it is good. If you just need the string, you should do away wit...

3 years ago | 0

Answered
How to plot a trajectory with varying colour?
"I'm trying to assign an independent variable to a data point in 2D through colour." You can choose any colour(s) you like. Ex...

3 years ago | 0

| accepted

Answered
Develop a reordering matrix based on stored vectors
order_old = [1 2 3 4 5 6]; order_new = [4 5 1 2 3 6]; Output = order_old.' == order_new

3 years ago | 0

| accepted

Answered
Retrieve App Designer textarea content along with the newline characters
The multi-line text is stored as a cell array of character vectors in the textarea's Value, so to present it with newlines, you ...

3 years ago | 1

| accepted

Answered
Extracting Corresponding values from an array
Example usage, function defined below. matrix = [1 2; 3 4; 5 6; 1 8] get_2nd_column_val(matrix,3) get_2nd_column_val(matrix,1...

3 years ago | 0

| accepted

Answered
Create function to convert data type as table: 2 errors
One problem appears to be that the function expects a table but you're giving it a categorical array. I can't say for sure becau...

3 years ago | 1

| accepted

Answered
How to iterate through the struct char to label a new struct correctly?
for x = 1 : length(theFiles) baseFileName = theFiles(x).name; %e.g. for x =1 , baseFileName = 'sample_1.mat' [~,fn,~] ...

3 years ago | 0

Answered
Polyfit function is returning a partial line of best fit
Rather than calling plot with the fitobject returned from fit, you can use coeffvalues to get the coefficients of the fitobject ...

3 years ago | 1

Answered
ASCII TO HAMMING CODE 7.4
I would check that you're putting the elements of encodedMsg in the right order here: encodedMsgStr = num2str(encodedMsg(:).');...

3 years ago | 0

| accepted

Answered
How do I create a loop to give me cut-off value
cutoff = 1500; vals = [200,450,950,1000,1200,1450,1550,1600,1650]; for ii = 1:numel(vals) if vals(ii) >= cutoff ...

3 years ago | 1

| accepted

Answered
made up function not running in matlab, error: unrecognized function or variable. How can I get this fixed?
Looks like the first three lines: image1 = imread('ex.tif'); [avg_profile, radius] = radialProfile(image1, 12); plot(radius, ...

3 years ago | 0

| accepted

Answered
how extract table RowNames based on table elements
% a table as you describe t = table([1;NaN;3;4;NaN],'RowNames',{'A';'B';'C';'D';'E'}) % extract RowNames of the NaN rows nan_...

3 years ago | 0

| accepted

Answered
How to extract column index based on value in another column?
% first I create a table of random data n_rows = 15; data = zeros(n_rows,4); for ii = 1:n_rows data(ii,:) = randperm(4);...

3 years ago | 0

Answered
How to assign 0 or 1 randomly to the coordinates?
val = randi([0 1], size(X)) ;

3 years ago | 0

Answered
Load multiple files on MATLAB
n_files = 10; VACF_all = zeros(n_files,100); % Pre-allocate a matrix to store all the VACF results. ...

3 years ago | 0

| accepted

Answered
Not able to combine data in cells of different sizes
Here's one way. The idea is to use NaNs to fill out the matrix you build. n_files = 30; n_c = 0; c = NaN(n_c, n_files); fo...

3 years ago | 1

| accepted

Answered
Looping through sets of names for a match and selecting variable with this name
You're comparing a numeric index (xx), which is between 1 and length(accvectors_name), with a length-3 character vector (ID). In...

3 years ago | 1

| accepted

Answered
How to eliminate a number of rows at certain points of a large data set?
If rawdata is your matrix: % number of rows in your matrix: N_rows = size(rawdata,1); % construct a logical vector of 500 t...

3 years ago | 1

| accepted

Answered
How can I plot contour lines on the generated map?
In your code, you make the map then create a new figure for each contour. Those new figures aren't going to have the map; the ma...

3 years ago | 0

| accepted

Load more