Answered
Creating a function that outputs a polynomial
tip: When you create a new function on matlab (right click directory>new file > function), it looks something like this: functi...

5 years ago | 0

Answered
Is there any function for calculating the size of a position vector in matlab?
use the norm() function. example: norm([1 2 3]) ans = 3.7417

5 years ago | 0

Answered
How to create variable to use on more than one function in App Designer?
https://www.mathworks.com/help/matlab/creating_guis/share-data-across-callbacks-in-app-designer.html you can store values in th...

5 years ago | 0

| accepted

Answered
how to cause a change in the colour of a push button every time it is pressed ?
function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved...

5 years ago | 2

| accepted

Answered
Extract data from array at set intervals to new array
you can use indexing. y(1:23:end)

5 years ago | 0

| accepted

Answered
How to create a random number that is a percent of each element in a vector
here's a small example: a = [100 200 300 400 500; 600 700 800 900 1000] bet = []; for i = 1:size(a,2) %for the number of colu...

5 years ago | 0

| accepted

Answered
Matrix dimension must agree
you are not using rand correctly. from the documentation: "X = rand returns a single uniformly distributed random number in the...

5 years ago | 0

Answered
How to joint together two matrix?
A =[4 4 4 4 ;3 3 3 3;2 2 2 2;1 1 1 1]; B = repmat(1:4,4,1); C = cell(1,numel(A)); for i = 1:numel(A) C{i} = [A(i) B(i)...

5 years ago | 0

Answered
How does I bring the line plot in front of the bar?
Use uistack(); a = plot(x,y) %let a be the handle to plot 1 b= plot(x2,y2) %let b be the handle to plot 2 uistack(a,'top') ...

5 years ago | 5

| accepted

Answered
Index in position 1 is invalid. Array indices must be positive integers or logical values.
this line may be the cause: bar(bi, pc(ctx(i), choices(j))); because for i = 1, ctx(1) = 0. you cant index pc...

5 years ago | 0

Answered
Adjust size of vector/matrix
f you want to set the first 50 elements of B to be equal to A: B(1:50) = A; If you mean to delete excess elements in B until y...

5 years ago | 0

| accepted

Answered
How can I handle visibility on/off for plot function?
For graphic objects, there is a 'Visible' Property that you can adjust. If you have a handle for your line object, for example:...

5 years ago | 2

Question


Table elements not updating automatically-- bug or setting? (R2018a)
I have a variable window open that is a table displaying my x y data. Sometimes it updates as I change the x y values, but there...

5 years ago | 0 answers | 0

0

answers

Answered
Need help creating a two separate matrices; one matrix is a 5x5 and has ones in columns 1, 3, and 5. The other matrix is also 5x5, but in the elements in the fifth column are equal to the row number that they are on.
if you're looking for hints, check out the functions: size() ones() zeros() and this documentation on array indexing: https...

6 years ago | 0

Answered
plot in predesigned figure
You can assign a handle to the axes of the figure, and reference them in your plot function. for example: fig1 = figure; a = ...

6 years ago | 0

| accepted

Answered
Matrix multiplication and addition
m1 = a(:,6); m2 = b(1:4,:)'; prod = m1.*m2; part_sums = sum(prod); r = part_sums(1); s = part_sums(2); ...

6 years ago | 0

Answered
How to get consistent subplot widths with legend outside?
You can assign a handle to the legends and set all their xpositions to be the same. Do the same for the subplots. ex: %some_x_...

6 years ago | 1

| accepted

Answered
graph multiple fields in a struct
fld = fieldnames(variable); %list of all field names.. data1, data2,data3... for i = 1:numel(fld) % for each field name ...

6 years ago | 0

| accepted

Answered
Can I create points on polygon with specific distance between them?
depends if your y values are equally spaced in the first place. Is this an appropriate workaround?: % add this to your plot h...

6 years ago | 0

Answered
How do I make a code that store large amount of information from excel into a matrix?
Are you trying to do this: m = numData1(:,[1:12]); this should give you a matrix with the first row corresponding to the eleme...

6 years ago | 0

| accepted

Answered
I have a matrix (57,3600,45), how can I create matrices with (3600,45)?
does this give you what you want? test_num = 1; M(test_num,:,:) %where M= your matrix

6 years ago | 0

Answered
greater than less than
here's an example: voltsadd_val = [1 5 3; -2 -5 5; 1 -5 3]; voltsadd_val(voltsadd_val>0) = 1; % if pos, 1 voltsadd_val(voltsa...

6 years ago | 0

Answered
I'm trying to create a shopping list using buttons and am having trouble getting my list to stack items
some suggestions: function oatmeal_fn(Oatmeal_h, evt, TOTAL) % i would remove TOTAL if you could, ...

6 years ago | 0

Answered
How to Rearrange a Matrix
% let M be your matrix of two columns ind = [2 4 6 7 8 12]; % desired indices new_M = M(ind,:)

6 years ago | 0

| accepted

Answered
How can I generate an array of binary data of this form?
N = 18; M = zeros(N); %preallocate space for i =1: size(M,1) ind = randperm(N); % generates random indices between 1:N ...

6 years ago | 1

Answered
Computing the median of a group except one member
Hello! Is this sort of what you're looking for? M=[1 2 3 6 5 4 2 3 4 1 5 6; 1 1 1 1 1 1 2 2 2 2 2 2; 2 4 6 5 7 8 3 7 5 7 5 3]'...

6 years ago | 1

| accepted

Answered
Trouble displaying the final count
just do this: search = 'CAT'; locate = regexp(DNA,search) count = numel(locate{1}) %number of times CAT appears edit: it s...

6 years ago | 0

| accepted

Answered
How can I make a push button in a uitable?
There is a callback property for the uitable called 'CellSelectionCallback' which will trigger a function each time you select ...

6 years ago | 1

| accepted

Question


Using cellfun() to set cell array of graphic objects 'Visible' Property to 'off'
I have a 1xn cell array of graphic objects-- currently I have the logic in a for-loop for j = 1:numel(uis) uis{j}.Visible ...

6 years ago | 1 answer | 0

1

answer

Answered
How to half the value of a constant inside an iteration?
maxiter = 100; iter = 1; x = 1:1:99; n = 8*(1/2).^x; % n = 8 , 4, 2, 0.5,... while iter< maxiter gamma = 10 * 10^(-n(it...

6 years ago | 0

| accepted

Load more