Respondida
Return row vector adding on to the end
myFibon(4) function seq = myFibon(x,seq) if nargin < 2 seq = []; end if x > 1 temp1 = myFibon(x-1,seq); tem...

más de 3 años hace | 0

| aceptada

Respondida
How to create time windows given start and stop indices
Here's one way: trainStarts = [2 10 15]; trainEnds = [6 12 21]; result = arrayfun(@(x,y)x:y,trainStarts,trainEnds,'UniformO...

más de 3 años hace | 0

| aceptada

Respondida
How to add the amount of two generated values in a graph?
x = []; taken_spots = []; %% Generate Random Numbers s = 10000; %total number of available parking spots n = s*5; %n = quant...

más de 3 años hace | 0

| aceptada

Respondida
Multiplying 3D array to 2D matrix error
If A is your 72*52*52 array and B is your 52*52 matrix, then: result = A .* repmat(permute(B,[3 1 2]),[size(A,1) 1 1]); No nee...

más de 3 años hace | 0

Respondida
Selecting middle of file name
If your file names are stored as a cell array of character vectors: fn = {'abcdefg89012mnopq' 'abcdefg89013mnopq' 'abcdefg89014...

más de 3 años hace | 0

Respondida
Enter the table of values used for this plot
x = [-5:-1 -0.8:0.2:-0.2]; x = [x -x(end:-1:1)] y = 1./x.^2 result = reshape([x; y],1,[])

más de 3 años hace | 0

Respondida
Handling cells which contains structures
% a cell array of structs with some stuff missing: c = { ... struct('field_1',struct('sub_field_1',1)) ... struct('fi...

más de 3 años hace | 0

Respondida
Create radiobutton without button group
I don't know why a radio button's parent must be a button group, but you can set the button group's BorderType to 'none', so tha...

más de 3 años hace | 0

Respondida
How to find corresponding indices?
% some data data = [0 10]+(1:10).' % whether to get each row: rows_to_get = [false; false; true; true; false; false; false; t...

más de 3 años hace | 0

Respondida
"char" doesn't always maintain orientation of input array
I imagine the rationale is that, in case the elements of the categorical array are multiple characters long, e.g.: categorical(...

más de 3 años hace | 0

Respondida
Reordering columns based on first row?
Using the elements of the first row of A as column indices in B: A = [ 5 4 1 2 0.5 0.7 ...

más de 3 años hace | 1

| aceptada

Respondida
How to set the x and y to log scale while plotting a function with fplot
fplot(@exp,[1e-4 10]) set(gca(),'XScale','log','YScale','log')

más de 3 años hace | 0

Respondida
How to find specific elements in a matrix
R55 = [2,4,6,9,11;7,8,9,10,6;1,2,6,4,5;,6,9,8,5,6;1,6,5,7,5] val = 6; Using a for loop: rows = []; columns = []; m = size(R...

más de 3 años hace | 0

| aceptada

Respondida
Processing data from loop
% empty table with two variables, X and Y: t = table([],[],'VariableNames',{'X' 'Y'}) Nframes = 3; % for each frame ... fo...

más de 3 años hace | 0

Respondida
Plot smooth lines from limit data with colormap and legend
cmap = [ ... 13 8 135; ... 67 3 158; ... 106 0 168; ... 145 14 163; ... 177 42 144; ... ...

más de 3 años hace | 0

Respondida
App designer push button and list option
Set the 'Enable' property of the pushbutton. https://www.mathworks.com/help/matlab/ref/matlab.ui.control.button-properties.html...

más de 3 años hace | 0

| aceptada

Respondida
How can I compare among three matrices ?
A = [10;26;30]; B = [12;25;35]; C = [15;29;9]; M = [A B C]; Mnew = M == min(M,[],2)

más de 3 años hace | 0

| aceptada

Respondida
how to call the function from the other file?
Remove the first line from rdnim.m: close all; clear all; clc; so that rdnim.m starts with the function keyword: function [in...

más de 3 años hace | 1

Respondida
Create a d x N matrix out of a d x 1 vector, where each column is a random permutation of the d x 1 vector
c = [11;23;39]; N = 4; d = numel(c); One way: A = zeros(d,N); for ii = 1:N A(:,ii) = c(randperm(d)); end disp(A) ...

más de 3 años hace | 0

Respondida
Using Nexttile or subplot in while and if loops ? Plotting issue
close all % Close pre-existing figures start_year = 1971; %represents the start year of the loop span = [2 5] %represents rows...

más de 3 años hace | 1

| aceptada

Respondida
how to I fill a vector with the results from my loop?
%inital set up %forces p=12; ql=2; qw=3; b=3; %locations za=6; xp= 5; xql=7; xqw=10; xa_all = 0:0.1:20; for ii =...

más de 3 años hace | 1

| aceptada

Respondida
How to add a graph with axes in a GUI
my_axes = axes('Units','normalized','Position',[0.05 0.3 0.9 0.65]);

más de 3 años hace | 0

Respondida
Cant use Excel names to fprintf?
gogn = readtable("Book1.xlsx", "VariableNamingRule","preserve"); [tblB,index] = sortrows(gogn); fname = tblB.Fornafn; % first ...

más de 3 años hace | 1

| aceptada

Respondida
Using different equations for a single line plot
close all ; %hertzian contact calculator for a cylinder clc; format long F= 5000 ; v1=0.3; v2=0.3; E1=700000; E2=700000; ...

más de 3 años hace | 0

| aceptada

Respondida
How to replace a subsection in a 5 x 5 matrix with a 4 x 2 matrix
R55 = [2,4,6,9,11;7,8,9,10,6;1,2,6,4,5;,6,9,8,5,6;1,6,5,7,5]; R55Mod = R55; R55Mod(1:4,3:4) = 1

más de 3 años hace | 0

| aceptada

Respondida
Change date InputFormat across a cell
load('OBS_MAX.mat') OBS_MAX = cellfun(@set_dates_format,OBS_MAX,'UniformOutput',false); function t = set_dates_format(t) ...

más de 3 años hace | 1

| aceptada

Respondida
why does my colorbar shift my second y axis?
clear all clc a=randi(10,10,20); x=linspace(-1,1,20); y=linspace(-1,1,10); imagesc(x,y,a) ax1=gca; ax2=axes('Posi...

más de 3 años hace | 0

| aceptada

Respondida
Plot Legend as 1 Row with 3 Variables?
Set NumColumns equal to the number of lines, in this case 3. % random data data1 = struct( ... 'Simulation_Time',0:100:14...

más de 3 años hace | 1

| aceptada

Respondida
How to create a list of matrices??
In MATLAB, use a cell array: C = {magic(4) eye(5) rand(3)} C{1} C{2} C{3} Or since all your matrices are the same size, use...

más de 3 años hace | 1

Respondida
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
clc clear L_s=180; L_m=710; L_h=740; L_e=3850; L_o=4720; Q_sh=67; Q_mh=36; Q_he=161; Q_eo=182; Q_oo=212; M=linspace(...

casi 4 años hace | 0

Cargar más