matrix

how to resolve index exceeds matrix dimensions in matlab?

孤街醉人 提交于 2019-12-31 06:21:01
问题 I am trying to read series of dicom images from a folder named as series 8.below is code to read series of dicom images from a particular folder.i am getting error index exceeds matrix dimensions at info = dicominfo(fullfile(fileFolder,fileNames{1})) . clear all; close all; clc; fileFolder = fullfile(pwd, 'series 8'); files = dir ( fullfile (fileFolder, '*.dcm')); fileNames = {files.name}; %examine file header (metadata , from dicom stack) info = dicominfo(fullfile(fileFolder,fileNames{1}))

Solving time-dependent Schrodinger equation using MATLAB ode45

元气小坏坏 提交于 2019-12-31 06:05:05
问题 The Schrodinger equation for a time-dependent Hamiltonian is: I try to implement a solver for the Schrodinger equation for a time-dependent Hamiltonian in ode45 . However, because the Hamiltonian $H(t)$ is dependent on time. I do not know how to do interpolation in ode45 . Can you give me some hints? psi0 = [0 1]; H = [1 0;0 1]*cos(t); %this is wrong, I do not know how to implement this and pass it to ode45 hbar = 1; t = [0:1:100]; [T, psi] = ode45(dpsi, t, psi); function dpsi = f(t, psi, H,

Show instance for matrix in Haskell

两盒软妹~` 提交于 2019-12-31 05:23:11
问题 I've been trying to create a show instance in order to visualize a given matrix and also, to create an outline with columns around and in between the matrix. What I managed to accomplish so far is the following: data Mat a = Mat [[a]] instance (Show a) => Show (Mat a) where show (Mat x) = "\n" ++ " ---\n"++unlines ( map (\r -> showRow r ++ "\n ---") x ) ++ "\n" where showRow list = "¦ "++unwords ( map (\v -> show v ++" ¦") list) Assuming we have a matrix Mat [[1,2,3],[4,5,6]] that we would

Matrix into JTable

南笙酒味 提交于 2019-12-31 05:19:10
问题 I need to fill a JTable with a static 2D array. I've created this model for the JTable : public class InsertMatToJTable extends AbstractTableModel{ String titre[] = {"age real", "sex real", "chest real", "resting_blood_pressure real","serum_cholestoral real","fasting_blood_sugar real","resting_electrocardiographic_results real","maximum_heart_rate_achieved real","exercise_induced_angina real","oldpeak real","slope real","number_of_major_vessels real","thal real", "class"}; String line; float

how to produce every permutation of positioning 20 values of -1 in a 1-by-41 vector of ones?

牧云@^-^@ 提交于 2019-12-31 04:50:11
问题 I have written different code to produce different permutations of ones and minus ones. they work for matrixes with small dimensions: for example: S=[-1 -1 1 1 1 1 1 1]; P=unique(perms(S),'rows'); produces: -1 -1 1 1 1 1 1 1 -1 1 -1 1 1 1 1 1 -1 1 1 -1 1 1 1 1 -1 1 1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 -1 1 1 1 1 1 -1 1 -1 1 1 1 1 1 1 -1 1 -1 -1 1 1 1 1 1 1 -1 1 -1 1 1 1 1 1 -1 1 1 -1 1 1 1 1 -1 1 1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 -1 1 1 1 1 1 -1 1 1 -1 -1 1 1 1 1 1 1 -1 1 -1 1 1 1 1 1 -1 1 1 -1 1 1 1

Stats on every n rows for each column

纵饮孤独 提交于 2019-12-31 04:19:06
问题 I would like to calculate the mean and standard deviation for every nth (in my case every 6) rows (or samples). The following function gives me the means for every 6 rows (96 rows gives me 16 mean values) colMeans(matrix(data.trim$X0, nrow=6)) I would like to do this for ALL columns (a total of 1280 mean values). I tried running this function: colMeans(matrix(data.trim, nrow=6)) but this does not work at all and I get the following error message: Error in colMeans(matrix(data.trim, nrow = 6))

OpenGL, problems with GL_MODELVIEW GL_PROJECTION

跟風遠走 提交于 2019-12-31 04:14:08
问题 Guys, I'm trying to finish up my homework but I'm having some problems here on these models on openGL... any Idea why is my draw not happening? One thing that strange is that if I change to gluPerspective it works.. #include <GL/glut.h> #include <stdlib.h> #include <stdio.h> static int shoulder = 0; static int elbow = 0; void init(void) { glClearColor(1.0, 1.0, 1.0, 0.0); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); /* BASE */ glRotatef((GLfloat) shoulder, 0.0, 0.0, 1

simple matrix multiplication in Spark

孤街醉人 提交于 2019-12-31 04:11:29
问题 I am struggling with some very basic spark code. I would like to define a matrix x with 2 columns. This is what I have tried: scala> val s = breeze.linalg.linspace(-3,3,5) s: breeze.linalg.DenseVector[Double] = DenseVector(-3.0, -1.5, 0.0, 1.5, 3.0) // in this case I want s to be both column 1 and column 2 of x scala> val ss = s.toArray ++ s.toArray ss: Array[Double] = Array(-3.0, -1.5, 0.0, 1.5, 3.0, -3.0, -1.5, 0.0, 1.5, 3.0) scala> import org.apache.spark.mllib.linalg.distributed.RowMatrix

How to get multiple matrices from large data sets based on year

房东的猫 提交于 2019-12-31 03:56:04
问题 before I start here is a a small subset of the data I'm working with, i apologize in advance for it being so large (note this is only the first 30 rows of an extremely large dataset: mydata<-structure(list(ParkName = c("SEP", "CSSP", "SEP", "ONF", "SEP", "ONF", "SEP", "CSSP", "ONF", "SEP", "CSSP", "PPRSP", "PPRSP", "SEP", "ONF", "PPRSP", "ONF", "SEP", "SEP", "ONF"), Year = c(2001, 2005, 1998,2011, 1991, 1991, 1991, 1991, 1991, 1992, 1992, 1992, 1992, 1992, 1992, 1992, 1992, 1993, 1994, 1994),

Making a matrix of a specific structure

荒凉一梦 提交于 2019-12-31 03:50:06
问题 Please note: I don't know where I am mistaking but I have spent whole day trying to solve this problem. So, I request not to discard it as duplicate question and treat this as a very specific question related to matrix structure. I have the following data.frame: dput(c.m.q) structure(list(ASK_Price = c(1801, 1687.3, 1687.2, 1688.95, 1687.15, 1688.95, 1687.5, 1688.85, 1689, 1688.95, 1687.5, 1688, 1688, 1687.5, 1689.95, 1685.85, 1689.9, 1689.95, 1688.8, 1688.95, 1687.15, 1687.2, 1690, 1688,