matlab

Matlab: Array of random integers with no direct repetition

早过忘川 提交于 2021-02-19 05:22:25
问题 For my experiment I have 20 categories which contain 9 pictures each. I want to show these pictures in a pseudo-random sequence where the only constraint to randomness is that one image may not be followed directly by one of the same category. So I need something similar to r = randi([1 20],1,180); just with an added constraint of two numbers not directly following each other. E.g. 14 8 15 15 7 16 6 4 1 8 is not legitimate, whereas 14 8 15 7 15 16 6 4 1 8 would be. An alternative way I was

Matlab: Array of random integers with no direct repetition

怎甘沉沦 提交于 2021-02-19 05:22:08
问题 For my experiment I have 20 categories which contain 9 pictures each. I want to show these pictures in a pseudo-random sequence where the only constraint to randomness is that one image may not be followed directly by one of the same category. So I need something similar to r = randi([1 20],1,180); just with an added constraint of two numbers not directly following each other. E.g. 14 8 15 15 7 16 6 4 1 8 is not legitimate, whereas 14 8 15 7 15 16 6 4 1 8 would be. An alternative way I was

How to control colorbar color ranges in Matlab plots?

让人想犯罪 __ 提交于 2021-02-19 04:27:06
问题 I have the following code: [X,Y,Z] = peaks(30); crange = 1.5; [maxval dummy] = max(Z(:)); [minval dummy] = min(Z(:)); % green, yellow, red cmap = [0 1 0; 1 1 0; 1 0 0]; figure colormap(cmap); surf(X,Y,Z); caxis([30 55]); cbh=colorbar; set(cbh,'Ytick',[30 32 38 55]); My goal is to set the limits of the color bar so that the colors are like this: green from 30 to 32 yellow from 32 to 38 red from 38 to 55 I believe I should somehow change the CData variable, so I used these lines of code without

How to control colorbar color ranges in Matlab plots?

∥☆過路亽.° 提交于 2021-02-19 04:27:05
问题 I have the following code: [X,Y,Z] = peaks(30); crange = 1.5; [maxval dummy] = max(Z(:)); [minval dummy] = min(Z(:)); % green, yellow, red cmap = [0 1 0; 1 1 0; 1 0 0]; figure colormap(cmap); surf(X,Y,Z); caxis([30 55]); cbh=colorbar; set(cbh,'Ytick',[30 32 38 55]); My goal is to set the limits of the color bar so that the colors are like this: green from 30 to 32 yellow from 32 to 38 red from 38 to 55 I believe I should somehow change the CData variable, so I used these lines of code without

Finding all combinations of multiple variables summing to 1

混江龙づ霸主 提交于 2021-02-19 04:09:13
问题 I am trying to solve the equation x1 + x2 + x3 + .... + xn = 1 where the values of all xi are restricted to [0, 0.1, 0.2, ..., 0.9, 1] . Currently, I am solving the problem by first generating an n-dimensional array mat , where at each element location the value is the sum of the axis values, which vary in axisValues = 0:0.1:1 : mat(i,j,k,...,q) = axisValues(i) + axisValues(j) + ... + axisValues(q). Then I search for all entries of the resulting array that are equal to one. The code (shown

Finding all combinations of multiple variables summing to 1

感情迁移 提交于 2021-02-19 04:05:14
问题 I am trying to solve the equation x1 + x2 + x3 + .... + xn = 1 where the values of all xi are restricted to [0, 0.1, 0.2, ..., 0.9, 1] . Currently, I am solving the problem by first generating an n-dimensional array mat , where at each element location the value is the sum of the axis values, which vary in axisValues = 0:0.1:1 : mat(i,j,k,...,q) = axisValues(i) + axisValues(j) + ... + axisValues(q). Then I search for all entries of the resulting array that are equal to one. The code (shown

MATLAB fast (componentwise) vector operations are…really fast

血红的双手。 提交于 2021-02-19 02:53:29
问题 I am writing MATLAB scripts since some time and, still, I do not understand how it works "under the hood". Consider the following script, that do some computation using (big) vectors in three different ways: MATLAB vector operations; Simple for cycle that do the same computation component-wise; An optimized cycle that is supposed to be faster than 2. since avoid some allocation and some assignment. Here is the code: N = 10000000; A = linspace(0,100,N); B = linspace(-100,100,N); C = linspace(0

MATLAB fast (componentwise) vector operations are…really fast

前提是你 提交于 2021-02-19 02:53:01
问题 I am writing MATLAB scripts since some time and, still, I do not understand how it works "under the hood". Consider the following script, that do some computation using (big) vectors in three different ways: MATLAB vector operations; Simple for cycle that do the same computation component-wise; An optimized cycle that is supposed to be faster than 2. since avoid some allocation and some assignment. Here is the code: N = 10000000; A = linspace(0,100,N); B = linspace(-100,100,N); C = linspace(0

Extracting EEG Components from Signal within MATLAB

那年仲夏 提交于 2021-02-19 02:34:07
问题 I have a simple EEG signal in MATLAB such as that shown in the figure below. And what I wanted was to extract the components of the EEG according to the following table. Delta - up to 4 Hz; Theta - 4 -> 8 Hz Alpha - 8 -> 13 Hz Beta - 13 -> 30 Hz Gamma - 30 -> 100 Hz In a first attempt to solve this problem I tried to build a bandpass filter with 'fdatool' from MATLAB to extract the component' theta 'signal, but without success. Along attached the code for the filter obtained with the 'fdatool

基于MATLAB的单级倒立摆仿真

↘锁芯ラ 提交于 2021-02-19 01:59:35
有关代码及word文档请关注公众号“浮光倾云”,后台回复A010.02即可获取 一、单级倒立摆概述   倒立摆是处于倒置不稳定状态,人为控制使其处于动态平衡的一种摆,是一类典型的快速、多变量、非线性、强耦合、自然不稳定系统。由于在实际中存在很多类似的系统,因此对它的研究在理论上和方法上均有重要意义。   单级倒立摆系统 ( Simple Inverted Pendulum System ) 是由倒立摆和小车两部分组成。小车依靠直流电动机施加控制力,可以在导轨上左右移动,其控制目标是在有限长导轨上使倒立摆能够稳定竖立在小车上而不倒,达到动态平衡 [1] 图1 倒立摆小车系统 Fig1. Inverted Pendulum on a Cart   图中 F 为施加于小车的水平方向的作用力, 是摆杆的倾斜角。若不给小车施加控制力,摆杆会左右倾斜,控制的过程即当摆杆出现偏角,在水平方向给小车以作用力,通过小车的水平运动,使摆杆保持在垂直位置,意即控制系统的状态参数,以保持倒立摆的倒立稳定。   倒立摆系统由6大部分组成,并构成一个闭环结构,包括计算机、数据采集卡、电源及功率放大器、直流伺服电机、倒立摆本体和两个光电编码器等模块,如图2所示。 图2 倒立摆系统结构组成示意图 Fig2 Structure of the Single Inverted Pendulum System 二