Community Profile

##### Last seen: Today
115 total contributions since 2014

View details...

Contributions in
View by

How to seperate an array into two?
You can directly index into your 1-D vector. V = rand(8,1); n = length(V); Vodd = V(1:2:n); Veven = V(2:2:n);

21 hours ago | 0

I have an equation with 3 variables that each have an allowable range of values, how can I compute all possible solutions by picking from the allowable range of values at random?
B = 1.71E11; F = @(E,Q,K) E.*B + Q.* (B./K); mnE = 0.02; mxE = 0.06; numval = 100; E = rand(numval,1) .*(mxE-mnE) + mnE; % ...

22 hours ago | 1

| accepted

How to read and write to global variables of shared library(using loadlibrary)?
You need to get the pointer first. Try the following to see if it works. Also you did not specify what data type the pointer i...

1 day ago | 0

| accepted

Bar chart with numerical x-axis treated as labels OR with thicker "bars"
categorical does not need you to supply the values as cellstring or string. You can straight away use it on a numerical array. ...

2 days ago | 0

| accepted

Why my for loop does not work correctly?
for i = 1:numel(Class1_mon_avg_synop) j = (i-1)*2; ave(i) = Class1_mon_avg_synop{1,i}.sum_rrr24(i); ALLMONTHS_cla...

2 days ago | 1

How to create a menu with checkbox in app designer?
There is a property "Checked" for uimenu. In app designer select the menu and in property inspector tick the checked box.

3 days ago | 0

How to extract text from .json files and combine them?
You can import your data into cell arrays filelist = {}; vals = cell(length(filelist),1); haveabstract = false(length(filelis...

4 days ago | 0

How to calculate the highest consecutive negative results in my code
Assuming your vector is called a a = randi([-10 10],2000,1); ag0 = a>=0; % idx of val greater then a id = cumsum(ag0 | circsh...

4 days ago | 1

Data comparison and storing
Humidity = str2double(Humidity(~ismissing(Humiditiy))); lowlimit = 40; highlimit = 50; outsidelimit = Humidity > highlimit ||...

4 days ago | 0

Efficiently copying values from one table two another in which unique values are columns
C = unstack(B,'volatility','days'); The function unstack will do exactly what you are trying to do. The first column would be...

4 days ago | 1

| accepted

Cannot create a pointer to a struct
You need to use the function libstruct https://www.mathworks.com/help/releases/R2020a/matlab/ref/libstruct.html https://www.ma...

7 days ago | 0

How to add multiple legends in app designer ?
Add a display name to each plot. then turn on the legends at the end % example ax = axes; hold(ax,'on'); for i = 1:10 p...

7 days ago | 1

| accepted

Run a Python Script to Stream Data
You should split your code into two functions. You can create a python function that instantiates the socket and return the soc...

8 days ago | 0

Extracting repeated rows from table data based on conditions
% a = sometable, % assume no repeat of columns 6:7 for combination of 1:5 [b,ia,ic] = unique(a(:,1:5),'rows'); n = accumarra...

10 days ago | 0

| accepted

Combine plots generated using for loop
Did you mean sub plots ? f = figure; tiledlayout(f,5,1); for i=1:5 ax = nexttile x = [0 : 0.01: 10]; y = i*sin...

11 days ago | 0

How to apply function on columns while skipping certain columns
m = rand(31413,950); allcols = 1:950; exccols = 1:10:950; applcols = allcols(~ismember(allcols,exccols)); out = max(m(:,appl...

15 days ago | 0

In MATLAB GUI, how can I display a set of elements such as edit text and slider only if I push the radiobutton?
If you are using app designer something like this will work for you. Essentially you can have an entire row or column of your g...

15 days ago | 0

% matrix = 11 x 3 ch = matrix(:,1); [u,~,ic] = unique(ch); maxba = accumarray(ic,matrix(:,2),[],@max); out = [u maxba]; i =...

16 days ago | 0

Extract data from all values of a containers.Map collection
I assume that each of value in the container is a struct with identical fields. You can just get all the values like this % M...

18 days ago | 0

Hey, Im trying to run this code but the run time is too long. can anyone help me out here plz
As a starting point you can vectorize your inner for loops m = repelem(1:s(1),1,s(2)); n = repmat(1:s(2),1,s(1)); a = cos((((...

21 days ago | 0

| accepted

How to insert y-coordinate into plot next to each point
total_num_attacks=[0,1,2,3,4,5]; attack_kill_array=[0,.2,.31,.39,.43,.46]; kill_chance_increase=[0,0,.38,.18,.1,.06]; max_att...

21 days ago | 0

Storing data in an array from a for loop
You don't need to read your file line by line. textscan can scan the entire file in one pass (unless the format spec keep changi...

21 days ago | 0

Use a wildcard to look for values in struct
Is there only one middle field ? If thats the case you can do as follows % s = your struct f = filednames(s); v = getfield(s...

21 days ago | 0

| accepted

How to input a specific data into Matlab Gui uitable via clicking a button?
The reason is because your second line of code overwrites your previous assignment. You need to specify the column in your code...

21 days ago | 1

| accepted

Find a specific set of values in a matrix
You can do this quite easily twocolmat = rand(100,2); idx = twocolmat(:,1) >= 0.2; col2vals = twocolmat(idx,2);

21 days ago | 2

How to use the fillmissing function to interpolate at certain points
You can directly use interp1 to interpolate at your desired time intervals. t = 1:100; v = zeros(1,100); % here v is the value...

21 days ago | 0

| accepted

Creation of a .dat files in a for loop
% assume some values mx_inelastic = rand(30001,2434); my_inelastic = rand(30001,2434); mz_inelastic = rand(30001,2434); phy...

22 days ago | 1

| accepted

How do I separate a data set into separate cell arrays according to the integer on the end of a string?
You need to extract the digit at the end. % c = yourcell array digit = regexp(c(:,4),'\d+\$','match','once'); [u_d,i,j] = uniq...

22 days ago | 0

| accepted

Double summation in matlab
You can define a function to calculate the expression inside the brackets. a = @(p,param)param.^p./factorial(p); % (param^n)/fa...

29 days ago | 1

| accepted