Community Profile

# Kevin Phung

175 total contributions since 2018

#### Kevin Phung's Badges

View details...

Contributions in
View by

How to add 0 in a column to form an array in which all columns are with equal rows?
here is an example: a = [1 2 3]'; b = [1 2]'; c = [1 2 3 4 5 6 7]'; sets = {a,b,c}; % let a, b, and c be your column sets. ...

1 month ago | 0

| accepted

Check for column in table
any(ismember(Table_1.Properties.VariableNames,'Column1')) strcmp works too, in place of ismember

1 month ago | 0

Find all lines of a matrix which have a matching pair of values
A = [1 2 3 4; 2 5 7 8; 4 5 7 9; 4 6 7 13; 6 8 13 15]; Pairs = [5 7; 4 7; 6 13]; index =zeros(size(Pairs,1),1); for i = 1:size...

3 months ago | 0

compare the elements of multiple matrix and return min and max matrix
A = [1 92 33; 4 15 66; 16 27 48]; B = [34 45 16; 67 38 19; 2 83 31]; C = [20 53 61; ...

3 months ago | 1

How to sum up multiple vectors, element by element, to recieve one final value?
example: W = [1 2 3 4 5]; O = [1 2 3 4 5]; %do the numerator first: E = W.*O; %element wise product %sum up the produ...

3 months ago | 1

| accepted

Array Operation with using another array
sum(k(m))

3 months ago | 0

| accepted

Question

How to Re-position DataCursormode 'Window'
So Matlab figures have a datacursormode that either show up as a datatip or a window. I would like to make use of the window bu...

3 months ago | 1 answer | 0

### 1

Count number of elements in a matrix more or less than given numbers
x = 10; y = 20; sum(A(:,2)<x | A(:,2)>y)

3 months ago | 1

| accepted

Replace largest elements in matrix with NaN
A =[17 2 5 68 79 28 900 17 77 63 90 87]; n = 3; elem = sort(A(:,1),'d'); elem =...

3 months ago | 1

| accepted

Plot using same colors
To plot in a specific color, scroll down in : https://www.mathworks.com/help/matlab/ref/plot.html so you can do something like...

3 months ago | 0

Find if max elements in array < or > a given number
a = [6 7 4 8 9]; val = numel(a); if sum(a >= val) > val/2 disp(['Max elements greater than or equal to: ' num2str(val)]);...

3 months ago | 1

| accepted

What's the best way to shorten this?
a for loop! https://www.mathworks.com/help/matlab/ref/for.html

3 months ago | 1

How to use windowkeypressfcn
function keyP(source, event) KeyPressed=event.Key; if strcmp(KeyPressed,'escape') view(3) end end It's as the error ...

3 months ago | 0

Why won't this program run?
STEPS = 100; tau = 10; t0 = 2*tau; dt = 1; t = [0:STEPS-1]*dt; gE = zeros(1,STEPS); for i = 1:STEPS a = dt*ST...

3 months ago | 0

| accepted

How to get a single value of an array through a function inside a script?
function Eg = Esrc(u,a) a = dt*u; %% I want to use the a that is defined above in the code. fo...

3 months ago | 0

| accepted

Question

How to find installation folder for matlab add-ons via command line?
Hi, I have a gui (made through a class method, in a class folder) that on start up checks whether or not the user has a specific...

4 months ago | 0 answers | 1

### 0

Updating variable matrix values to static boxes in GUI !
make sure your function main_file_run() actually has an output, so in that function: function x = main_file_run() % blah blah...

4 months ago | 0

Using a while loop with a vector
Your while loop actually only runs once because after the first iteration, B>360 returns a logical array of [0 0 0 1 1 1], so it...

4 months ago | 0

| accepted

Question

How would these functions behave after compiling from GUI -> Executable?
I have designed a matlab gui (not with guide or appdesigner) and am interested in eventually compiling it into an executable fil...

4 months ago | 0 answers | 0

### 0

animate for a given time
tic toc is used to see how long processes take in your script. This is not relevant to what you are trying to do. You should ta...

4 months ago | 0

index in matrix using loop
m = [0.5 0.5; 0.25 0.5; -0.5 -0.5] % your sample matrix f = m(m>0) * A + fill c = m(m<0) *A + cut ^ this only return the va...

4 months ago | 0

I am having problems in anonymous function (y=@(x)(...))
let me know if this is what youre trying to do with your anon functions: function y = fun(a,x) y = sum(triu(repmat(flip(x.^(1...

4 months ago | 0

Plot is not working
Your T is a vector, and your Y is a scalar. There is no singular line because it is actually plotting all 5 points as individual...

4 months ago | 0

| accepted

why nothing is happening when i am calling other function in other button?
what is supposed to be happening? My guess is that something IS happening, except your callback functions are not returning anyt...

4 months ago | 0

GUI Ignoring Changes to figure.Pointer Without a pause() command
add in a drawnow() command after you change the cursor.

5 months ago | 0

| accepted

Calling function with set parameters
You can put all those graphic objects into an array, same for the strings and other parameters. then use a forloop. short examp...

5 months ago | 0

| accepted

Filtering matlab table like a database or via dropdown menu
Yes! I would suggest creating the gui through uicontrol() programmatically (not via GUIDE): https://www.mathworks.com/help/matl...

5 months ago | 0

| accepted

Photo and Text with Dropdown Menu
use uicontrol to create a text box: https://www.mathworks.com/help/matlab/ref/uicontrol.html and imshow to create your image: ...

5 months ago | 0

How do I create a call back function that updates a "Label" when I push a button? (Calculator)
assign a tag to your label, which I assume is a text graphic object. example: txt1.Tag = 'label1'; function button_1callbac...

5 months ago | 1