Answered
Filling an array with color points
I think this is what you were going for: j = 34; g = 3; A = zeros(j,g); for i= 1:j A(i,:) = [0 (i-1)/j 1]; end disp(...

4 years ago | 0

Answered
How to extract an element from a ''vector'' of function handle
It seems like you want a cell array of function handles: f = {@(x1,x2,x3)x1*2-x3; @(x1,x2,x3)x3*x1-x2; @(x1,x2,x3)x1-x2^2} f{1...

4 years ago | 0

Answered
Camera and view function and properties
When you do ax = get(gca); you are storing the axes properties in a struct called ax. (In this case these are the initial prop...

4 years ago | 1

| accepted

Answered
How do i delete red box?
Put a semicolon at the end of the line where you call work5() x = 0.5; A=work5(x); % semicolon here to suppress output func...

4 years ago | 0

Answered
adding answers into cell array
One way: answers = {}; for n = 1 : 10 % My very complex computation res = sprintf('The answer is %i', randi(5)); ...

4 years ago | 0

| accepted

Answered
How do i make this form with matrix ?
A = work5(0.5); function A=work5(x) m=1; y = 10:10:160; for k = y n=1:k; a= sum(nthroot(n.^2,5)./((3.^n).*(n...

4 years ago | 0

| accepted

Answered
Why are there variations in values when using floor function?
0.15/0.05 0.15/0.05 - 3 So 0.15/0.05 returns a number that's a little bit less than 3, as it turns out (so floor(0.15/0.05) re...

4 years ago | 0

| accepted

Answered
How to stop running the code for conditional logical output?
Using return like that is completely appropriate for what you want to do, but you must make sure all of your function's outputs ...

4 years ago | 1

| accepted

Answered
Indexing an array with find(contains()) while retaining duplicate elements.
You can use ismember: A = {'000000699';'000002373';'000002374';'000002378';'000002385';'000002387';'000002389';'000000895';'000...

4 years ago | 1

| accepted

Answered
add unknown number of vectors into a matrix
A = []; for i = 1:unknown_num v = 1x2 vector from file A(end+1,:) = v; end

4 years ago | 0

Answered
Graph from 0º to 360º
plot(Mtaco(:,1), mod(Mtaco(:,5),360),'o'), grid on, title('Orientacion');

4 years ago | 0

Answered
How to compare 5 column matrix with 10 column matrix
One way is this: signal = repmat(fastSMACalcs,1,slowSMARange) > repelem(slowSMACalcs,1,fastSMARange); or this: signal = repel...

4 years ago | 0

| accepted

Answered
How to count the values in Column 1 if the corresponding values are different in Column 2 & 3.
Time = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]; State1 = [1 1 1 2 2 2 2 2 2 2 2]; State2 = [1 1 1 1 1 1 1 1 2 2 2]; Time(...

4 years ago | 0

Answered
Extracting numerical data from a char vector
% making up a character vector as described: lat = 40.23; lon = -32.674; heading = 66.96; str = sprintf('%8.4f\n%8.4f\n%8.4f...

4 years ago | 0

Answered
Can I partition a matrix ito several seperated parts ?
A = [2;2;-3;4;5;6;7;-8;9;-6;5;4;-2;1;3;-9;8;7;4;-5;6;3;2;-1;4;-7;-8;5;-6]; % maybe this: B = A(1:7); C = A(8:14); D = A(15:2...

4 years ago | 0

| accepted

Answered
How to stack columns in a matrix?
A = 1:12 B = reshape(A,3,[]).'

4 years ago | 0

Answered
How to set colour bar scale as a power of 10?
This will make a log-scale colorbar with limits and ticks based on the vector UU (it doesn't go down to 1e-9 because UU doesn't ...

4 years ago | 0

| accepted

Answered
Matrix calculation(replacing a new value instead of matrix element)
The result T you get is correct. The confusion is because of how T is displayed in the Command Window. You can look at one eleme...

4 years ago | 1

Answered
Count number of rows that meet criteria based on elements in other rows
nnz(A(:,1) == 2 & A(:,3) == 1) % 1st column is 2 & 3rd column is 1 where A is your matrix

4 years ago | 0

Answered
Contour not rendered for non-finite ZData
In the line where you calculate PHI you will see two other warnings, both about "matrix is singular ...", which is because X/Y a...

4 years ago | 1

| accepted

Answered
How do I omit a range of points from line?
I'm not sure if this is what you want, but here's how you can remove data before t = 1, for instance: S = load('data.mat'); ...

4 years ago | 0

Answered
removing 0 values from an array while maintaining an array
If you know there are always the same number of zeros in each column, you can reshape after removing them: % random matrix with...

4 years ago | 1

Answered
Remove 2D array elements outside of a range
Try one of these two things, depending on whether x_pts corresponds to the rows or columns of wmax: % if x_pts corresponds to t...

4 years ago | 0

Answered
How to plot multiple graphs on the same figure using a loop?
Maybe something like this (create one figure with both the life grid and the number of live cells over time): clear all close ...

4 years ago | 0

Answered
Separating age into young and old groups
% 50 random ages between 1 and 100: ages = randi(100,1,50) % age limit/threshold for separation: age_limit = 35; % logical...

4 years ago | 0

Answered
Failing to procedurally generate structures with for loops
% number of rows of properties rows = 11; % define array of field names fieldnames = ["pressure" "Temperature" "massflow" "en...

4 years ago | 0

Answered
Removing repeated in order elements from array?
Your approach will work; you just have to start at the second-to-last element instead of the last: array = [ 1 1 1 2 2 3 3 3 1 ...

4 years ago | 0

Answered
Dataset reshape and create new columns
Here's one way to do it: % read the file: data = readcell('example_data.csv'); data(1:10,:) % get the types and ids: C = re...

4 years ago | 0

| accepted

Answered
Can I use a variable string to index into a structure?
I think what you want is dynamic field names. % An example struct: S = struct('OptionA',1,'OptionB',2) choice = "OptionB"; S...

4 years ago | 1

| accepted

Answered
I hope to use enough points and show only a few repetitions to make a smooth graph.
% cos(t) has period 2*pi % cos(2*pi*t) has period 1 % cos(2*pi*1500*t) has period 1/1500 % % pick t values that span a few p...

4 years ago | 0

| accepted

Load more