http://www.mathworks.nl/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-07-30T00:43:03Ztag:www.mathworks.nl,2005:Question/1437872014-07-29T20:04:56Z2014-07-30T00:43:03ZNeural Network neuron values<p>I'm interested in seeing how and when the inputs and weights are modified using a pre-trained standard patternnet classifier. For example using the crab dataset (6 inputs, 2 layers, 2 outputs, and 10 hidden neurons). Can the steps be confirmed as:</p><pre> 1) For each of n hidden neurons sum product of input i(1-6) with input weight(n)(1-6)
2) Add specific bias(n) to sum
3) Normalize to -1:1 range using mapminmax
4) For each of 2 output neurons sum product of hidden neurons with layer2 weights
5) Add layer 2 specific bias.
6) Normalize again using mapminmax</pre>Riley/matlabcentral/answers/contributors/5346829-rileytag:www.mathworks.nl,2005:Question/1436422014-07-28T18:26:14Z2014-07-30T00:42:16ZSpecifying which category is the reference level for glmfit<p>When using glmfit() with categorical predictor variables, how is reference level determined? Is there a way to specify which category should be the reference level instead of the default?</p><p>The equivalent in R is the relevel() command.</p>the cyclist/matlabcentral/answers/contributors/1841757-the-cyclisttag:www.mathworks.nl,2005:Question/1435632014-07-28T04:35:48Z2014-07-30T00:41:02ZConvertir archivos *.mat a *.m<img src = "/matlabcentral/answers/uploaded_files/15889/mathscritp.PNG"><p>Buenas.
Si me pueden colaborar con un problema.
Entrene redes neuronales con el NNTOOL de matlab y los guarde en el disco (se crean con extensión *.mat por defecto) y cuando abro la red entrenada en con el MathScript de Labview unos caracteres que nada que ver con la topología de la red entrenada.
Viendo el editor de Matlab crea archivo *.m el cual puede leer sin ningún problema MathScript de Labview (lo muestra tal como está).
Ahora mi consulta es como exporto la red neuronal entrenada para que pueda leer el MathScript o como puedo convertirlo en un archivo *.m.</p><p>Saludos</p>Edwin Cuevas/matlabcentral/answers/contributors/4451270-edwin-cuevastag:www.mathworks.nl,2005:Question/1438042014-07-30T00:35:18Z2014-07-30T00:35:18ZHow to include a spline interpolant in simulink as a function into a block?<p>Hello</p><p>I have 2 following arrays
x=[0:0.01:0.25];
a= [1 1 1 1 0.995 0.977 0.965 0.958 0.957 0.955 0.951 0.96 0.978 0.979 0.98 0.982 0.984 0.986 0.988 0.99 0.992 0.994 0.996 0.998 0.998 0.998 ];</p><p>I need a function which depict the data as a signal in simulink into a block, but is not possible because the polynomial function doesn't fit perfectly with the data, so the function which is created by regression is no good for my work, then i made a spline interpolant and it is a good representation of the curve, but i don't know how to include it in simulink.</p><p>Thank you for attention</p>Juan Urrego/matlabcentral/answers/contributors/3005934-juan-urregotag:www.mathworks.nl,2005:Question/1437922014-07-29T21:14:55Z2014-07-30T00:33:14ZStrange Parse Error for Superclass; MATLAB Version Problem?<p>Hello!</p><p>I am using vendor supplied code to stream data from MATLAB to hardware. All of the code is in the following GitHub: https://github.com/analogdevicesinc/mathworks_tools/tree/master/iio_sys_obj</p><p>Anytime I attempt to run either of the m files, I instantly receive the following error:</p><p>"Error using iio_sys_obj
The specified superclass 'matlab.system.mixin.CustomIcon' contains a parse error or cannot be
found on MATLAB's search path, possibly shadowed by another file with the same name."</p><p>I know the code was written using 2013b, and I am currently stuck with 2013a. Could that be a source of the problem?</p><p>The code uses an additional Windows software driver found under the "Downloads" section here(but I do not think it has anything to do with this particular error): <a href = "http://wiki.analog.com/resources/tools-software/linux-software/libiio/clients/matlab_simulink#downloads">http://wiki.analog.com/resources/tools-software/linux-software/libiio/clients/matlab_simulink#downloads</a></p><p>Thank you for any assistance!</p><p>Will</p>Will/matlabcentral/answers/contributors/5488863-willtag:www.mathworks.nl,2005:Question/1438022014-07-29T23:56:23Z2014-07-29T23:56:23ZHow do I find the largest opening and the width of that opening?<img src = "/matlabcentral/answers/uploaded_files/15991/crackedge.png"><p>I used a Canny edge detection method to obtain the above image of a crack. Now I would like to find the largest opening and the width of that opening.</p><p>I'm not too sure how to approach this but any help would be appreciated.</p><p>Thanks</p>Duncan/matlabcentral/answers/contributors/5351214-duncantag:www.mathworks.nl,2005:Question/1438002014-07-29T23:48:15Z2014-07-29T23:56:01ZList of MATLAB code analyzer message IDs<p>I'd like to find a list of the message IDs of the built-in code analyzer warning messages used for suppressing those messages either on a single line or in a file (see <a href = "http://www.mathworks.com/help/matlab/matlab_prog/check-code-for-errors-and-warnings.html#brqxeeu-167">here</a> ). I know you can search by message ID, but the list in the preferences (see <a href = "http://www.mathworks.com/help/matlab/matlab_env/about-code-analyzer-preferences.html#bs24a39-1">here</a> ) doesn't actually show the ID itself. Any help would be appreciated, thanks!</p>Oren/matlabcentral/answers/contributors/2501615-orentag:www.mathworks.nl,2005:Question/1271132014-04-25T07:35:43Z2014-07-29T23:53:43ZHow to save workspace except for one structure field?<p>I want to save the workspace except for a variable and a field in a structure.</p><p>I know i can do this to not save a variable, but i want to also not save struct.field</p><pre> save('Workspace.mat','-regexp','^(?!(VariableName)$).');</pre>Mohammad/matlabcentral/answers/contributors/5283187-mohammadtag:www.mathworks.nl,2005:Question/1437062014-07-29T09:44:14Z2014-07-29T23:52:03ZResizing bug when using multiple popup menus on figure?<p>For some reason, if I create more then one pop up menu on a figure and then resize the figure, only the first one is resized correctly while the other ones are cropped.</p><pre class="language-matlab">figure
</pre><pre class="language-matlab">pu = uicontrol('Style', 'popup', 'String', 'A|B|C');
set(pu, 'fontunits', 'normalized', 'Units', 'normalized', 'Position', [0.01 0.8 0.08 0.05]);
</pre><pre class="language-matlab">pu = uicontrol('Style', 'popup', 'String', 'A|B|C');
set(pu, 'fontunits', 'normalized', 'Units', 'normalized', 'Position', [0.01 0.7 0.08 0.05]);
</pre><p>This is what it looks like at first:</p><img src = "/matlabcentral/answers/uploaded_files/15934/pre.PNG"><p>After resizing it :</p><img src = "/matlabcentral/answers/uploaded_files/15936/full.PNG"><p>And then resizing it back:</p><img src = "/matlabcentral/answers/uploaded_files/15937/back.PNG">Mohammad/matlabcentral/answers/contributors/5283187-mohammadtag:www.mathworks.nl,2005:Question/1386472014-06-29T13:56:22Z2014-07-29T23:50:21ZSerial read for Arduino Due in S-function<p>Hey there,</p><p>I'm trying to send two different data sets from Matlab to the Arduino Due over the Serial Port. The reason I'm not using the external mode is because it's slowing the Arduino down to a speed, where it's not able to run in realtime anymore.
I've tried to implement the code similar to an example on the Arduino HP ( <a href = "http://arduino.cc/en/Tutorial/ReadASCIIString">ReadASCIIString</a>), but it seems that Matlab isn't properly including the Serial library. I was following the <a href = "http://www.mathworks.de/matlabcentral/fileexchange/39354-device-drivers">Device Driver tutorial</a> to create the S-function, but as soon as I use the Serial.begin function, I get the following error when building the code:</p><pre> The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
The build failed with the following message: "D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-gcc" -I"D:/Documents/MATLAB/untitled_rtt" -I"D:/Documents/MATLAB" -I"D:/Programme/MATLAB/R2014a/extern/include" -I"D:/Programme/MATLAB/R2014a/simulink/include" -I"D:/Programme/MATLAB/R2014a/rtw/c/src" -I"D:/Programme/MATLAB/R2014a/rtw/c/src/ext_mode/common" -I"D:/Programme/MATLAB/R2014a/rtw/c/ert" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/system/libsam" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/system/CMSIS/CMSIS/Include" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/system/CMSIS/Device/ATMEL" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/cores/arduino" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/cores/arduino/USB" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/variants/arduino_due_x" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino/include" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/libraries/Servo/src" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/libraries/Servo/arch/sam" -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -mcpu=cortex-m3 -mthumb -I. -D"MODEL=untitled" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"printf=iprintf" -D"F_CPU=84000000" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_ROTH_DUE_=" -D"ARDUINO=154" -D"ARDUINO_SAM_DUE=" -D"ARDUINO_ARCH_SAM=" -D"__SAM3X8E__=" -D"USB_PID=0x003e" -D"USB_VID=0x2341" -D"USBCON=" -D"_RTT_NUMSERVOS_=0" ./serial_20140629_1_wrapper.c ./ert_main.c ./untitled.c ./untitled_data.c ./IPAddress.cpp ./Print.cpp ./Reset.cpp ./RingBuffer.cpp ./Stream.cpp ./UARTClass.cpp ./USARTClass.cpp ./CDC.cpp ./HID.cpp ./USBCore.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./cortex_handlers.c ./cxxabi-compat.cpp ./hooks.c ./iar_calls_sam3.c ./itoa.c ./syscalls_sam3.c ./wiring.c ./wiring_analog.c ./wiring_digital.c ./wiring_pulse.cpp ./wiring_shift.c ./variant.cpp ./io_wrappers.cpp
./serial_20140629_1_wrapper.c: In function 'serial_20140629_1_Outputs_wrapper':
./serial_20140629_1_wrapper.c:42: error: 'Serial' undeclared (first use in this function)
./serial_20140629_1_wrapper.c:42: error: (Each undeclared identifier is reported only once
./serial_20140629_1_wrapper.c:42: error: for each function it appears in.)
./serial_20140629_1_wrapper.c: In function 'serial_20140629_1_Update_wrapper':
./serial_20140629_1_wrapper.c:62: error: 'Serial' undeclared (first use in this function)
cs-make: *** [serial_20140629_1_wrapper.o] Error 1</pre><pre> The build process will terminate as a result.</pre><pre> The build failed with the following message: "D:/Programme/MATLAB/SupportPackages/R2014a/arduino- 1.5.4/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-gcc" - I"D:/Documents/MATLAB/untitled_rtt" -I"D:/Documents/MATLAB" - I"D:/Programme/MATLAB/R2014a/extern/include" -I"D:/Programme/MATLAB/R2014a/simulink/include" - I"D:/Programme/MATLAB/R2014a/rtw/c/src" -I"D:/Programme/MATLAB/R2014a/rtw/c/src/ext_mode/common" -I"D:/Programme/MATLAB/R2014a/rtw/c/ert" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/system/libsam" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/system/CMSIS/CMSIS/Include" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/system/CMSIS/Device/ATMEL" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/cores/arduino" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/cores/arduino/USB" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/hardware/arduino/sam/variants/arduino_due_x" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino/include" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/libraries/Servo/src" -I"D:/Programme/MATLAB/SupportPackages/R2014a/arduino-1.5.4/libraries/Servo/arch/sam" -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -mcpu=cortex-m3 -mthumb -I. -D"MODEL=untitled" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"printf=iprintf" -D"F_CPU=84000000" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_ROTH_DUE_=" -D"ARDUINO=154" -D"ARDUINO_SAM_DUE=" -D"ARDUINO_ARCH_SAM=" -D"__SAM3X8E__=" -D"USB_PID=0x003e" -D"USB_VID=0x2341" -D"USBCON=" -D"_RTT_NUMSERVOS_=0" ./serial_20140629_1_wrapper.c ./ert_main.c ./untitled.c ./untitled_data.c ./IPAddress.cpp ./Print.cpp ./Reset.cpp ./RingBuffer.cpp ./Stream.cpp ./UARTClass.cpp ./USARTClass.cpp ./CDC.cpp ./HID.cpp ./USBCore.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./cortex_handlers.c ./cxxabi-compat.cpp ./hooks.c ./iar_calls_sam3.c ./itoa.c ./syscalls_sam3.c ./wiring.c ./wiring_analog.c ./wiring_digital.c ./wiring_pulse.cpp ./wiring_shift.c ./variant.cpp ./io_wrappers.cpp
./serial_20140629_1_wrapper.c: In function 'serial_20140629_1_Outputs_wrapper':
./serial_20140629_1_wrapper.c:42: error: 'Serial' undeclared (first use in this function)
./serial_20140629_1_wrapper.c:42: error: (Each undeclared identifier is reported only once
./serial_20140629_1_wrapper.c:42: error: for each function it appears in.)
./serial_20140629_1_wrapper.c: In function 'serial_20140629_1_Update_wrapper':
./serial_20140629_1_wrapper.c:62: error: 'Serial' undeclared (first use in this function)
cs-make: *** [serial_20140629_1_wrapper.o] Error 1</pre><p>Despite the fact I included the Arduino.h Simulink apparently doesn't know what to do with the Serial command.
Does anyone know how to solve this problem?</p>Paul/matlabcentral/answers/contributors/3227570-paultag:www.mathworks.nl,2005:Question/1437952014-07-29T21:57:18Z2014-07-29T23:39:07Zmerge datset one to many<pre class="language-matlab">Help~
I have a panel data, for example:
</pre><pre> A=[firm1_1970, firm1_1971,...firm1_1990, firm2_1970, firm2_1971,...firm2_1985,...,firm100_1995].</pre><pre class="language-matlab">As you can see, the dataset has many years, and in each year there are observations of a number of firms.
</pre><pre class="language-matlab">Now I have another dataset which is the interest rate for each year, for example:
</pre><pre> B=[r_1970, r_1971, r1972,..., r_1990]. </pre><pre class="language-matlab">I need to merge the two datset, but the join function seems not work because the 'Keys' (which is year) is not unique in A (the panel data). Is there any way to make such "one-to-many" merge? Many thanks.
</pre>Qifan/matlabcentral/answers/contributors/4725950-qifantag:www.mathworks.nl,2005:Question/1437532014-07-29T14:58:41Z2014-07-29T23:38:44ZHow can I approximate a certain section of a vector to remove noise?<p>I have some plots of S-parameters from a network analyzer, and they have a large amount of noise around 2.4 GHz. I am relatively certain that this noise is due to the Wi-Fi signal in the lab where I am working, so I would like to remove this section of the vector entirely and replace it with an approximation of what the line should look like. These vectors are complex, which complicates the issue because if I use local linear approximation, the real and imaginary components turn out alright, but the magnitude still looks pretty bad. I've tried using some sort of interpolation function (like spline or pchip) but I can't seem to get it to do what I want, which is to entirely remove one section of the vector and replace it with values that fit with the curve before and after. I've attached a few plots to show the issue. The [Raw] plots are straight from the network analyzer, and the [Corrected] plots have simply been "fixed" with local linear approximation on both the real and imaginary components. Thanks!</p>Adam Horton/matlabcentral/answers/contributors/5488371-adam-hortontag:www.mathworks.nl,2005:Question/1437962014-07-29T22:35:05Z2014-07-29T23:28:21Zis there a mat file loading error or memory leak in matlab 2013a?<p>I have a bunch of mat files that I saved. They are all more-or-less the same and contain three structures with a bunch of fields. The largest structure is about 500 MB, but trimming it down doesn't seem to change things. I would like to reload the mat files one at a time, but I can't because I get an error when I load them. I also have matlab 7.01 and it doesn't have the problem even though the mat files were all generated in 2013a.</p><p>The error message just says "error using load, can't read file" so it doesn't have any diagnostically useful information. If I shut down matlab and restart it, then I can read the first mat file that I try to, but I get this error message on the 2nd. If I then clean up memory (clear;close all;fclose all;pack), I can load the second mat file, but I get an error loading the 3rd. If I clean up the memory again, I still get the error loading the third and I am stuck. A coworker with the same version of matlab on a newer better computer with a different OS has the samne problem.</p>jim Martin/matlabcentral/answers/contributors/5488990-jim-martintag:www.mathworks.nl,2005:Question/1437942014-07-29T21:23:27Z2014-07-29T23:26:03ZStrange graph artifact when performing diff() of a high order<p>I think it has something to do with values going below eps within the code but I'm not sure. Is there a simple fix or do I have to rework the code entirely?</p><pre class="language-matlab">clearvars;
</pre><pre class="language-matlab">x1 = 0; %Start
x2 = 4*pi; %End
I = 1000; %Steps
h = (x2-x1)/I; %Step size
N = 5; %Number of derivatives
</pre><pre class="language-matlab">x = linspace(x1,x2,I);
y = exp(1/2*x); %Base function
dydx = zeros(N, I-N); %Preallocation
</pre><pre class="language-matlab">for n = 1:N
diffVector = diff(y,n)/h^n; %Calculates the nth derivative
dydx(n,:) = diffVector(1:I-N); %Stores it in the derivative array
end
</pre><pre class="language-matlab">plot(x(:,1:I-N),dydx,x,y) %Plots all derivatives
</pre><p>The code is just an exercise to find the nth derivative of a function (in this case exp(1/2x))</p><p>When N = 5 it seems to work fine. But if I change it to N = 7 I get some freaky graph output. This may also occur if I change I by a certain amount. Here are the graphs of each:</p><img src = "/matlabcentral/answers/uploaded_files/15985/normalPlot.png"><p><<</p><img src = "/matlabcentral/answers/uploaded_files/15984/abnormalPlot.png"><p>>></p>Cory Nezin/matlabcentral/answers/contributors/5488921-cory-nezintag:www.mathworks.nl,2005:Question/1437992014-07-29T23:23:50Z2014-07-29T23:23:50ZHow to change the color of an object(say ball) upon selection in simulink?<p>How to change the color of an object(say ball) upon selection in Simulink?</p>janani/matlabcentral/answers/contributors/5134187-jananitag:www.mathworks.nl,2005:Question/1436952014-07-29T08:34:09Z2014-07-29T23:12:16ZI need to write a script file that takes the coefficients of a quadratic and calculates the roots after testing them so that the least amount of calculation is done? <p>I have started with a code to simply calculate two roots of a quadratic function:</p><pre class="language-matlab">function [x1, x2] = quadraticRoots(a, b, c)
% Function to calculate the roots of the quadratic equation:
% a*x^2 + b*x + c = 0
% USAGE: [x1, x2] = quadraticRoots(a, b, c)
% INPUTS: a, b and c - the three coefficients
% OUTPUTS: x1 and x2 - the two roots of the equation
</pre><pre class="language-matlab">s = sqrt(b^2 - 4*a*c);
x1 = (-b+s)/(2*a);
x2 = (-b-s)/(2*a);
</pre><p>but don't know where to go from here?</p>Brittany/matlabcentral/answers/contributors/5462438-brittanytag:www.mathworks.nl,2005:Question/1437982014-07-29T22:48:29Z2014-07-29T23:05:08ZCommunication between two or more GUIs <p>I've a GUI(i.e. lets call it 'First')through which i can choose to open other GUIs(let's call them 'Second' and 'Third').I want to put a 'pushbutton' on the 'First'GUI that allows me to manipulate the figure on the different axes of the 'Second' and 'Third' GUIs. So, i choose with the 'First'GUI if use either 'Second' or 'Third' GUI; once i've chosen that i start to work just with the GUI that i chose (so the Third one or Second ones). Now i want to have a pushbutton not on each GUIs (Second or Third) but only on the First one in order to manipulate the figure on the axes 1 of the Second or Third (depends on which one i've previously chosen). Furthermore this pushbutton that i want is optional and i need to refresh my axes after used that.
I've done my best to explain the situation,please if you know any solution help me out!!Thank yo so much!!</p>Letizia/matlabcentral/answers/contributors/5345192-letiziatag:www.mathworks.nl,2005:Question/1436672014-07-28T23:16:38Z2014-07-29T22:55:50ZNeed to find files in a dir structure with similar but not identical names<p>I am trying to pull data from multiple files in a directory. I have written a for loop to get to the specified file, but when I search for the file using an * is cannot be found. For example, the file name 072814_Nominal.xls and another file in the same directory might be called 081213_Nominal.xls. I want to pull date from only files with "Nominal" in the name. I have tried using the below loop</p><pre class="language-matlab">D=dir(pathname);
for i=1:length(D)
if D(i).name=='*Nominal.xls' %this line is trouble - says matrix dimensions must agree
filename=fullfile(pathname,D(i).name);
temp(i)=xlsread(filename,'Sheet1','R4');
else
end
end
</pre><p>but I am getting the "Error using ==", "matrix dimensions must agree" error and I cannot find a way to make Matlab find the file that looks like 'Nominal' or 'Nominal.xls' (I have tried both). Please help!</p>Alex/matlabcentral/answers/contributors/4187053-alextag:www.mathworks.nl,2005:Question/1424482014-07-18T20:00:31Z2014-07-29T22:54:24Zblood vessel segmentation help<p>Hi,</p><p>I want to segment cerebral blood vessels from angiogram images?</p><p>Results which I got are very disappointing.</p><p>Any help or suggestions about image enhancement and segmentation are really appreciated.</p><p>This is an example of images to be segmented: <a href = "https://copy.com/ezNK3fM6sVNs">https://copy.com/ezNK3fM6sVNs</a></p><p>I do some processing but it is insufficient</p><p><a href = "https://copy.com/BzpfTBTe4Foe">https://copy.com/BzpfTBTe4Foe</a></p>rose rose/matlabcentral/answers/contributors/3612391-rose-rosetag:www.mathworks.nl,2005:Question/1437972014-07-29T22:42:51Z2014-07-29T22:49:37ZMultiplot figure in Simulink<p>I was watching the "Simulations and Reporting Made Easy for Signal Processing Systems" Webinar and saw multiple scopes(plots) running in real time in one figure (see attached screenshot). Keep in mind that the data in figure is updating as the simulation is running. I'd like to know how this is achieved in Simulink. I was hoping the demo shown in the Webinar was an actual MATLAB demo but it wasn't. Any help and advice would be greatly appreciated.</p>Mark/matlabcentral/answers/contributors/4489662-marktag:www.mathworks.nl,2005:Question/1437912014-07-29T20:35:58Z2014-07-29T22:43:03ZHow can I generate a grid schematic in MATLAB?<p>Hi guys,
I am currently working on a GUI to model the effects of low temperature on a PV array. The GUI (as made from the GUIDE) as of now takes in user inputs from text boxes in order to change some of the parameters of the PV modules (such as short circuit current and ideality factor).</p><p>However, the GUI ideally should be able to output a grid of cells whose dimensions correspond to however many cells are wired in series and in parallel. The user would then click on individual cells and be able to change the individual characteristics of each cell and view its IV curve.</p><p>How can you generate a grid of images that can change according to user input? For example if the user states that there are 2 rows of 5 cells wired in series connected to each other in parallel, the GUI will display a 2x5 array of cells. I have the actual equations written for manipulating the IV curves already written but I don't know how to generate this grid of cells.</p><p>Thanks in advance!</p>Roel/matlabcentral/answers/contributors/5486651-roeltag:www.mathworks.nl,2005:Question/1437682014-07-29T16:38:01Z2014-07-29T22:42:28ZModify DICOM elements without modifying PixelData<p>I am writing a program that reads in DICOM images, modifies elements of the header so they will be regrouped in our PACS, and writes that back out as a new file. The problem I am encountering is that the writing of the new file causes the pixel data to be recompressed, resulting in a difference from the original.
Here's a simple example:</p><pre class="language-matlab">metadata = dicominfo('MyDICOM.dcm');
X = dicomread(metadata);
% Maybe modify some header elements here
dicomwrite(X, 'MyDICOM_new.dcm', metadata, 'createmode', 'copy', 'WritePrivate', true);
X2 = dicomread('MyDICOM_new.dcm');
imshowpair(X, X2, 'diff');
</pre><p>I was expecting the two images to be identical, but they are different (I believe they are JPEG compression differences).</p><p>I also tried the dicomanon() function, but it also seems to recompress the image data. In my code I played with changing the new file format to be uncompressed by using a different TransferSyntax, but my multi-frame images exploded in size.</p><p>How can I modify DICOM header elements without causing the pixel data to change?</p><p>Thank you.</p>Scott/matlabcentral/answers/contributors/156533-scotttag:www.mathworks.nl,2005:Question/1069752013-11-20T19:31:01Z2014-07-29T22:26:05ZError downloading Simulink Model to Arduino Mega 2560 Rev3<p>Hi,</p><p>I'm using Matlab 2013a (on a Windows 8 64-bit PC) with Arduino support package 3.0. Downloading models to an Arduino UNO is wokring without problems. But I can't download any model to a new Arduino Mega 2560 Rev3. Tested with the arduinomega2560_gettingstarted model.
When Simulink says "Downloading.." RX/TX LEDs are just blinking twice and I get the following error:</p><p>_The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
Could not download the model to the target hardware. Verify the connection between the computer and target hardware.</p><p>The build process will terminate as a result.</p><p>Caused by:
Could not download the model to the target hardware. Verify the connection between the computer and target hardware._</p><p>But the target is definitely connected, and downloading programs with Ardino IDE is working fine.
I've also tested this on a different PC with Windows 7 with the same result.
Can anyone give me a hint please?</p>Arne/matlabcentral/answers/contributors/4376028-arnetag:www.mathworks.nl,2005:Question/1437902014-07-29T20:24:03Z2014-07-29T22:15:29ZMatlab FOR Loop help!<p>_ <b>I'm trying to get this function to work. But i keep getting an error. I am trying to determine the amount in the savings account for next 18 years, which is represented by x(k) in an array. Problem is that only the first value for the first month shows up in the array._ * _ *</b> _</p><pre class="language-matlab">clc,clear
% Variable declaration
% x will be used to store the value of the new balance
% a will be used to store the value of the old balance
% i will be used to store the value of the interest rate
% c will be used to store the value of the user's contribution
% Variable initialization
a = input('Enter a value for the initial balance: ');
i = input('Enter a value for the interest rate: ');
c = input('Enter a value that you will contribute: ');
% Calculation
month = 1:12:216;
x=zeros(length(month));
for k=1:length(month);
x(k) = a + i(k) + c
end
</pre>Dylan Flores/matlabcentral/answers/contributors/5441890-dylan-florestag:www.mathworks.nl,2005:Question/1433732014-07-25T19:49:34Z2014-07-29T22:15:02ZUsing sbiofit to estimate/fit a complex model based on multiple measurments<p>Hi,</p><p>I have a rather complex enzyme-kinetic model. For didactic purposes I will just give a simplified version here. The problem should be eminent anyway. I'll also drop intermediate steps in the reaction.</p><p><b>E, F</b> : Enzymes. <b>A, B</b> : Substrates. <b>Q, R</b> : Products.</p><pre class="language-matlab">E + F + A + B <-> E + F + Q + B <-> E + FQB <-> E + F + Q + R
k21,k12 k32,k23 k34,k43
</pre><p>I did measure the concentration of Product "R". I altered the Substrate "A" in multiple series.</p><p>My aim is to estimate the rate parameters. I created a model containing all differential equations. I used sbiofit which works, but now I got the following two problems:</p><ol><li>How can I perform parameter estimation/fit on "all my measurements" at once. I do not want to fit measurement Nr. 1, then Nr. 2 etc. Reason: sbiofit will return totally different Parameter Estimates for each measurement. (Yes, this might be because my problem is "over-parametrized" if I fit each measurment at once.)</li><li>During the fit, sbiofit yiels negative rates. How can I avoid that?</li></ol><p>Any hints, also beyond Matlab, are very appreciated!</p><p>Best,
Vincent</p>Vincent/matlabcentral/answers/contributors/2936441-vincenttag:www.mathworks.nl,2005:Question/1437762014-07-29T18:40:08Z2014-07-29T21:26:32ZHelp with plotting needed!<p>Hello all.</p><p>I have 100 element cell array, and each element represent a lund cell. Each element in cell array is av matrix of 1X1000 of intensities (each element in this matrix is the data recording per hour). I want to plot each lund cell (100 of them) on a raster plot with x as the time axis and the lund cell # on the y-axis.</p><p>I am not sure how to plot all the matrices of all 100 cells using <b>imagesc</b> and was wondering if I could please have some urgent help. Thank you in advance.</p>cocopuffs/matlabcentral/answers/contributors/5467782-cocopuffstag:www.mathworks.nl,2005:Question/1437122014-07-29T10:15:33Z2014-07-29T21:25:25ZCan any one give me an example about "How to write an array of string values into the Simulation Item 'Bucket Brigade.ArrayOfString' of Matrikon OPC SImulation Server using Matlab and OPC Toolbox" ?<p>I am trying to perform the OPC Write of certain signal values computed from the Simulink model running on a Target PC into the Simulation Items of Matrikon OPC Simulation Server through Matlab GUI.</p><p>Practical Scenario: Simulink model is build from Host PC (equipped with Matlab/Simulink, OPC Toolbox, xPC Target and MatrikonOPC Simulation Server) and kept running on the Target PC (equipped with an xPC Target real-time kernel) using the '.dlm' application file of the Simulink model.</p><p>The Build process behind the '.slx' Simulink model, Download of its respective '.dlm' application file onto the Target PC and Start of the application in the Target PC are being performed through Matlab GUI.</p><p>Until now, i had no difficulty in performing the OPC Write of certain signal (here signal data type is 'double') values and single string value into the Simulation items 'Bucket Brigade.Real4', 'Bucket Brigade.Real8' & 'Bucket Brigade.String' of Matrikon OPC Simulation Server through Matlab GUI.</p><p>Approach: The following is the Matlab GUI code where i am trying to perform the OPC Write of certain signal values and single string value into the Simulation items 'Bucket Brigade.Real4', 'Bucket Brigade.Real8' & 'Bucket Brigade.String' of Matrikon OPC Simulation Server</p><pre> % --- Executes on button press in btStartApp.
function btStartApp_Callback(hObject, eventdata, handles)
% hObject handle to btStartApp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</pre><pre> % cd(handles.options.guioptions.dlmpath);</pre><pre> writeToStatus('Status: Starting Application........', handles);</pre><pre> try</pre><pre> start(handles.tg); % Start application</pre><pre> %Set the stop time display
set(handles.tbStopTime,'String',['Stop Time: ' num2str(get(handles.tg,'StopTime'))]); </pre><pre> set(handles.btStopApp,'Enable','on'); % Enable the Stop push button
set(handles.btStartApp,'Enable','off'); % Disable the Start push buttonS
set(handles.btConnect,'Enable','off'); % Disable the Connect push button
set(handles.btDownload,'Enable','off'); % Disable the Download push button</pre><pre> % % OPC Initialisation
da = opcda('localhost','Matrikon.OPC.Simulation.1');%defines the Local Host as MatrikonOPC Server
connect(da);%connects to MatrikonOPC Server
opcregister('install', '-silent');%if not able to connect then silently install the opc
connect(da);%connects to MatrikonOPC Server
grp = addgroup(da, 'Group0'); %make a Group "Group0"
grpIDS = {'Bucket Brigade.Real8','Bucket Brigade.Real4','Bucket Brigade.ArrayOfString'}; %list out all dataIDS
grp_itm = additem(grp, grpIDS); %an itm object is created with listed items tags
set(grp,'UpdateRate',0.5);</pre><pre> % Store handles to connection and group in figure
setappdata(handles.tg, 'dahandle', da);
setappdata(handles.tg, 'grouphandle', grp);</pre><pre> cla (handles.axes1,'reset');
cla (handles.axes2,'reset');
cla (handles.axes18,'reset');
cla (handles.axes19,'reset');</pre><pre> writeToStatus('Status: Application Running', handles);</pre><pre> guidata(hObject,handles); % Update handles structure</pre><pre> start(handles.t) % Start Timer object</pre><pre> catch ME
writeToStatus(['Error: Application could not be started: ' ME.message], handles);
end</pre><pre> end</pre><pre> function xPC_UpdateStates(obj,event, hObject)</pre><pre> handles = guidata(hObject);
grp = getappdata(handles.tg, 'grouphandle');</pre><pre> try
if strcmp(get(handles.tg,'Status'),'stopped') % Check if application still running</pre><pre> btStopApp_Callback(hObject,event, handles);
end</pre><pre> %call event handler
err = do_check_events(handles);</pre><pre> if isobject(err)
btStopApp_Callback(hObject,event, handles);
stop(handles.tg);
throw(err);
end</pre><pre> catch ME
writeToStatus(['Error xPC_UpdateStates: Timer function execution error: ' ME.message], handles);
%errordlg(ME.message);
end</pre><pre> % Display Simulation Time
set(handles.tbExecTime,'String',['Execution Time1: ' num2str(get(handles.tg,'exectime'))]); drawnow; % Display execution time</pre><pre> id_sig1 = getsignalid(handles.tg,'Sine Wave');
id_sig2 = getsignalid(handles.tg,'Sine Wave1');
%
% Display Amplitude of Sine Wave
set(handles.tbAmpSine,'String',['Amplitude: ' num2str(getsignal(handles.tg,id_sig1))]); drawnow; % Display sine wave amplitude</pre><pre> % Get signal values
num_p = [getsignal(handles.tg,id_sig1) getsignal(handles.tg,id_sig2)];
cell_p = num2cell(num_p);</pre><pre> % Get string values
ch1_p = strcat({get(handles.btMC_text,'String')},{get(handles.btMacCut,'String')});
str_p = cellstr(ch1_p);</pre><pre> ct_ = cat(2,cell_p,str_p);</pre><pre> end</pre><p>I get the following warning when i am trying to perform the OPC Write of an array of string values into the Simulation Item 'Bucket Brigade.ArrayOfString':</p><pre> Warning: One or more items could not be written.
Bucket Brigade.ArrayOfString returned 'Type mismatch.' </pre><p>Has anyone tried to perform the OPC Write of an array of string values into the Simulation Item 'Bucket Brigade.ArrayOfString', please give me your invaluable input!</p><p>Additional Info:</p><p>Host PC: Equipped with Matlab R2012b Win 32-bit, OPC Toolbox 3.1.2, xPC Target 5.3, MatrikonOPC Simulation Server</p><p>Target PC: Equipped with a xPC Target Real-time kernel</p><p>Pre-Requisties Performed: Host-Target TCP/IP communication was established successfully</p><p>BR,</p><p>Sriniwas</p>Sriniwas Maddukuri/matlabcentral/answers/contributors/4603886-sriniwas-maddukuritag:www.mathworks.nl,2005:Question/1436712014-07-29T01:05:20Z2014-07-29T21:24:27ZWhat is the syntax to access a particular member in an array?<p>Hi, I have an array x=[1 2 3 4 5].</p><p>I then manipulate x, e.g. (A*x/B+C-D)...How can I determine the third member of the manipulated array?</p><p>This works but i feel there is a simpler way:</p><p>temp=(A*x/B+C-D);</p><p>temp(3)</p><p>Is there a way to do something like</p><p>(A*x/B+C-D)(3)?</p>Rainer/matlabcentral/answers/contributors/4041116-rainertag:www.mathworks.nl,2005:Question/1436492014-07-28T20:42:40Z2014-07-29T21:20:19ZVariable for loop step size<p>Hi All,
I am searching for a way to constantly change the step size during the for loop execution. Here is the code I'm working with.</p><pre class="language-matlab">lambda = 405; % Wavelength of laser light (nm)
dx = zeros(1000,1); % Preallocation of matrix storage
for d1=0:1000;
dx(d1+1) = 4*cos((pi*d1)/lambda)^2; % Save interation in dl, intensity interference equation
end
plot(dx)
</pre><p>Ideally, I would like the step size to be related to a function like f(x)=x^2. (This is only an example, the real function would be a sphere) Where if x=1 then f(1)=1. But if x=2 then f(2)=4. So the step size is going like: 1,4,9,12... I don't know if a for loop would be the right function to use. Any help is appreciated.</p>Travis/matlabcentral/answers/contributors/5429538-travistag:www.mathworks.nl,2005:Question/1437932013-11-21T05:00:00Z2014-07-29T21:18:03ZHow to replace string in a line that matches a regular expression and write it to a file?<p>How can I find a match in a string, based on a regular expression (pattern) and replace it with suitable text? How can I write this replaced text to a file?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.nl,2005:Question/1436572014-07-28T21:19:30Z2014-07-29T21:16:39ZHow to locate the the position of a 3D subimage in larger image in Matlab?<p>I have a 3D subimage saved as X.mat , which is a subimage of the 3D image Y.mat. How can I find the position of this subimage in the image Y?</p><p>Can anyone help me?</p><p>Thanks,</p>margol/matlabcentral/answers/contributors/5441036-margoltag:www.mathworks.nl,2005:Question/1437452014-07-29T14:12:58Z2014-07-29T21:15:52Zi want to know the pixel intensity value in an image but it gives different results using data cursor and command.which one is correct? and why it is showing differently?<p>let A is image</p><p>i want to know intensity value at (25,170).so by using command A(25,170) we can find intensity value but,using data cursor it shows different intensity value</p>Mahesh Kumar/matlabcentral/answers/contributors/5020465-mahesh-kumartag:www.mathworks.nl,2005:Question/1437052014-07-29T09:42:43Z2014-07-29T21:09:42ZHow to overlay a surf and a picture ?<p>Hello there,
I'm trying to a cartography from a file and a picture.</p><pre class="language-matlab">file=importdata('file.dat');
img=imread('picture.png');
x=0:1:100; %fil row
y=0:1:100; %file column
figure
hold on
surf(x,y,file);
shading interp
view (0,270);
imshow(img);
hold off
</pre><p>But my problem is that I want a transparency on my picture. I want white pixels to be transparent..</p><p>Thank you very much for your help
Dagan</p>Dagan/matlabcentral/answers/contributors/5487817-dagantag:www.mathworks.nl,2005:Question/1436812014-07-29T03:55:29Z2014-07-29T20:53:36ZHow to print path in figure title? It's screwing up my TeX markup<p>What I want to achieve is a 3-line title over a plot which looks like this:</p><pre> General Title
File name
Path where file lives</pre><p>(The file name and path name refers to the file I used to do the calculations.) The different lines would have different properties -- for instance the General Title would have a larger font size than the two lines below it. Everything works as intended except for the path -- that screws up everything. If I exclude the path name, I can generate a nice 2-line title like this:</p><pre class="language-matlab">title({'\fontsize{16}Correlation Over Time';...
['\fontsize{9}\itFile\rm:',FileName]})
</pre><p>Note how I use TeX commands. It works as intended. As soon as I try to include the pathname, it all breaks. This is my attempt, just extending the logic of the above:</p><pre class="language-matlab">title({'\fontsize{16}Correlation Over Time';...
['\fontsize{9}\itFile\rm:',FileName];...
['\fontsize{9}\itPath\rm:',PathName]})
</pre><p>The TeX markup syntax and Windows path specification both use the '\' character, so matlab interprets the '\' characters in the PathName string as TeX commands. As a result, the entire title command breaks down, and it just spits out all the characters inside the parentheses unformatted. Is there any way for me to get around this?</p><p>Thanks!</p>Alexei/matlabcentral/answers/contributors/5084669-alexeitag:www.mathworks.nl,2005:Question/1437812014-07-29T19:07:22Z2014-07-29T20:32:11ZDisplay time stamp into array.<p>My script gives output time stamp values in the below format ;</p><p>Time = 1360884246206630</p><p>Time = 1360884677434684</p><p>Time= 1360884943992713</p><p>This is Unix time stamp, so I want to display this time in the array like this ;</p><p>Time = [1360884246206630, 1360884677434684, 1360884943992713]</p><p>Any help will be appreciated.</p>Chiranjibi/matlabcentral/answers/contributors/5372183-chiranjibitag:www.mathworks.nl,2005:Question/1437822014-07-29T19:17:28Z2014-07-29T20:31:26ZError using sym/subsindex (line 1555) Indexing input must be numeric, logical or ':'.<p>I tried to solve a system of non liniear equations and generate a steady state curve. I kept getting the message: " Error using sym/subsindex (line 1555) Indexing input must be numeric, logical or ':'.</p><p>Error in Steadystate (line 53) [x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11]= solve(..."</p><p>Here is the part where I kept getting a wrong message and everything was not definied as symbols in here is a constant being specified before:</p><pre> syms x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 positive</pre><pre> %x1=Qs x2=Ql x3=Qar/qa x4=X x5=Xar x6=i(extracellular) x7=c
%x8=I(intracellular) x9=C x10=PrgB x11=loopO
%x12=donor density x13=recipient density</pre><pre> [x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11]= solve(...
x10==value,...pick a value for PrgB
x11==N*x8^4/(x8^4+Kb*x9^4),...
x1*(lamQs+muD)==(kPqloop*x11+kPqunloop*(N-x11))*(Kq*x5)/(1+Kq*x5),...
x2*(lamQl+muD)==(kPqloop*x11+kPqunloop*(N-x11))/(1+Kq*x5),...
x3*(lamQar+muD+kar*x5+kar*x4)==kPqloop*x11+kPqunloop*(N-x11),...
x4*(lamX+muD+kar*x3)==kxloop*x11+kxunloop*(N-x11),...
x5*(lamXar+muD+kar*x3)==kXarloop*x11+kXarunloop*(N-x11)-...
(kPqloop*x11+kPqunloop*(N-x11))*(Kq*x5(1+Kq*x5),...
x6*lameI==ki*(x1+x2)*DDensity-kTi(x6-x8)*DDensity,...
x8*(lamiI+muD)==kTi*(x6-x8),...
x9*(lamiC+muD)==kTc*(x7-x9),...
x10*(lamPrgB+muD)==kdown*x2,...
x1, x2, x3, x4, x5 ,x6, x7, x8, x9, x10, x11, 'Real',true);</pre><p>Please help</p><p>Thanks,
Vu</p>Vu/matlabcentral/answers/contributors/5488787-vutag:www.mathworks.nl,2005:Question/1437842014-07-29T19:34:38Z2014-07-29T20:31:06ZLogical indeexing and finding the corresponding value at a particular instance<p>This is what I have:</p><p>- One cell array, lets call it test:</p><pre> A 1 2
B 2 3
C 3 4
D 4 5 </pre><p>- Another cell array, lets call it test_2:</p><pre> Q 2 3
R 3 4
T 3 3
U 4 3 </pre><p>- What I need to get is a vector. And I am trying to do this in a loop, if test(:,2)> test_2{a,2} then test(:,4)=test_2{:,1} at that instance. I am appending test with a 4th column.</p><p>- Basically, I am trying to find when one column becomes greater than the other and find the corresponding adjacent row value at that instance.</p><p>Thank you!</p>Ariel/matlabcentral/answers/contributors/3239340-arieltag:www.mathworks.nl,2005:Question/1437852014-07-29T19:49:39Z2014-07-29T20:29:28ZHow can i go about plotting this??<p>My objective is to plot my initial angle vs the time it takes for this object to hit the ground.</p><p>-I have each of the values for angular acceleration, angular velocity and angular position.</p><p>-I know that when the angular velocity is zero, that the object hits the ground,</p><p>-I also know that when the angular position is 1.57(radians) that the object will hit the ground.(teacher told me)</p><p>-my initial angle is the set of values as follows:
inital_angle=[5:1:20]</p><p>My problem is that i don't know how exactly i can go about plotting this on matlab. How can i account for the time that is takes for the object to hit the ground??</p><p>Here is the information that i have as matlab shows it. The 2nd column in the command window is the angular position (with .0873 as my inital angle), and the 3rd column is angular velocity.</p><img src = "/matlabcentral/answers/uploaded_files/15976/q4.PNG">David/matlabcentral/answers/contributors/5441517-davidtag:www.mathworks.nl,2005:Question/1437522014-07-29T14:57:55Z2014-07-29T20:27:30ZHow to Delete Non-Numeric Columns from Table<p>I'm using readtable to load data from a text file. Some columns have text in them; others don't. I want to effectively delete the columns that have at least one entry of non-numeric data, so that I can convert the remaining table to an array (using table2array).</p><p>How can I do this?</p>Kevin/matlabcentral/answers/contributors/3741898-kevintag:www.mathworks.nl,2005:Question/1434482014-07-26T14:13:47Z2014-07-29T20:24:06ZR2014b: up-arrow in command line now ignores case (never did before)<p>Assume that the following two lines are in the command history:</p><p>> R = rand(100,1);</p><p>> r = min( R );</p><p>Later I want to recall the first of the two commands. In R2013a and earlier versions if I typed</p><p>> R<up-arrow></p><p>the command line would respond with</p><p>> R = rand(100,1);</p><p>Now with R2014a</p><p>> R<up-arrow></p><p>yields</p><p>> r = min( R );</p><p>Apparently the history command line completion is now ignoring case. I do not like that. Is there someway that I can get the old behavior back?</p>Alan Peters/matlabcentral/answers/contributors/2467902-alan-peterstag:www.mathworks.nl,2005:Question/1437882014-07-29T20:15:12Z2014-07-29T20:15:12ZHow can I link to a library in a Simulink s-function for RaspberryPI as target system?<p>Hello,
I am trying to access a MySQL database from Simulink running on a RaspberryPI as target Hardware.
My approach is to write an S-Function containing the C code to do the database operation.</p><p>The C code itself depends on "libmysqlclient-dev" and can be compiled successfully on the PI directly by linking to "-lmysqlclient".</p><p>But when I insert the code in the s-function, I don’t know where to add the linking argument.</p><p>I so far tried to place the argument at various places in the configuration of the s-function and the C/C++ code generation and always received the error message that there is a undefined reference to the MySQL functions or that the library could not be found.</p><p>When I opened the Makefile that is generated each time the code is prepared to be run on the PI there were several linking arguments like "-pthread" but the "-lmysqlclient" never appeared.</p><p>Now my question is, where and how can I do the linking to the library?</p><p>Are there more elegant ways to access the database?</p><p>Thanks in advance</p><pre class="language-matlab">//example code to demonstrate the problem
#include <stdio.h>
#include <stdlib.h>
#include <mysql/mysql.h>
</pre><pre class="language-matlab">int main(int argc, char **argv)
{
printf("MySQL client version: %s\n", mysql_get_client_info());
exit(0);
}
</pre>ANK/matlabcentral/answers/contributors/5473916-anktag:www.mathworks.nl,2005:Question/1437782014-07-29T18:52:28Z2014-07-29T20:09:58Zhow do i plot a rectangle havng cetain dimensions and inside it even number of parametric cordinates such dat the centres of all cordinates and centre of rectangle coincide?<p>i have to define a plan geometry in which my parametric input will be numb of columns..i wish to put columns in such a way dat dey are symetrically placed inside the rectangle..</p>Saurabh/matlabcentral/answers/contributors/5488736-saurabhtag:www.mathworks.nl,2005:Question/1422812014-07-17T19:43:51Z2014-07-29T20:02:26ZCount the number of times a value occurs in a specific of an array<p>Given a array, is there any way to count the number of times a value occurs within a specific row of that array?</p><p>For example, if I have a array:</p><pre> A=[1,2,5,2,3,4,2; 4,2,1,5,3,2,3; 1,4,2,3,2,2,1];</pre><p>I want to know how many times the value '2' occurs in the second row</p><p>Thanks</p>Tyler/matlabcentral/answers/contributors/5449628-tylertag:www.mathworks.nl,2005:Question/1437862014-07-29T19:50:58Z2014-07-29T19:50:58ZReducing or simplifying the **symbolic** product of two integrals <p>I wish using the Symbolic toolbox to guide me in rather simple but tedious work. Part of the formulae I deal with includes the square of a generic integral (or the product of two integrals):</p><p>syms t xi h(t)
a = int(h(xi), xi, 0, t)
pretty(a*a)</p><p>QUESTION:
Is there any command that I can use to have MATLAB deriving the following expansion (where eta is a symbolic variable of course)</p><p>int(int(h(xi), xi, 0, t) * h(eta), eta, 0, t)</p><p>i.e., automatically recognising that the product of the above integrals is the double/iterated integral of the product??</p><p>That would simplify greatly my life! Without it I am frustrated and resorted to paper and pen: I must in fact anyway evaluate the expected value of the generic quantities h(xi) as random variables and having MATLAB just simplifying the expression a tiny bit would have helped.</p><p>Tnx!</p>Michele Giugliano/matlabcentral/answers/contributors/2049928-michele-giuglianotag:www.mathworks.nl,2005:Question/1436682014-07-28T04:00:00Z2014-07-29T19:48:07ZWhy does MATLAB crash resulting in a stack trace with "mexRunMexFile"?<p>When I run my program, MATLAB crashes with the following stack trace:</p><p>Stack Trace (from fault): </p><p>[ 0] 00000000771dc4a5 MSVCR100.dll+00246949 ( strcpy+000085 ) </p><p>[ 1] 000007feeaee775c calc_auto.mexw64+00030556 ( mdlOutputs+003148 )</p><p>[ 2] 000007feeaee680c calc_auto.mexw64+00026636 ( mexFunction+003100 )</p><p>[ 3] 00000000592b0f83 libmex.dll+00069507 ( mexRunMexFile+000131 ) </p><p>[ 4] 00000000592afce2 libmex.dll+00064738 ( inSwapMexfileReader+000226 ) </p><p>[ 5] 0000000074e8c80d m_dispatcher.dll+00051213 ( Mfh_file::dispatch_fh+000509 ) </p><p>[ 6] 0000000074ee5e8b m_dispatcher.dll+00417419 ( mdAcquireMatlabFunction+002507 ) </p><p>...</p><p>The same program used to work in a previous release of MATLAB. Is this a bug in the new release causing MATLAB to crash?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.nl,2005:Question/1437832014-07-29T19:34:19Z2014-07-29T19:43:47ZGUIDE outputting a .txt file<p>Hi all,</p><p>I'm working on a GUI that generates reports based on some input data. I'm currently trying to produce a text based output that can be printed. Ideally, I'd like to make and save a .txt file that can be copied into a LaTeX compiler.</p><p>So, from the callback on a pushbutton, how would I output a .txt file that could be saved somewhere?</p><p>This is my first experience with MATLAB coding, so any help would be appreciated. Even just pointing me in the right direction would be great.</p>Julien/matlabcentral/answers/contributors/3688859-julientag:www.mathworks.nl,2005:Question/1437692014-07-29T16:58:18Z2014-07-29T19:31:55ZMaximize minimum optimization problem <p>Hello!
I would like to ask for your help concerning the following optimization problem as I am trying to get familiar with such kind of optimization...</p><img src = "/matlabcentral/answers/uploaded_files/15966/opt.png"><p>Can someone help me about how to write down my objective function and the first inequality constraint (in order to include them in the <i>intlinprog</i> solver)? I mainly don't know how to describe the 'ε' as the obective function... The rest of the constraints can be easily formed in matrices.</p><p>Thank you in advance!</p><p>Regards,</p><p>Chris</p>Chris B/matlabcentral/answers/contributors/4829225-chris-btag:www.mathworks.nl,2005:Question/1409862014-07-08T18:28:59Z2014-07-29T19:12:24ZAre there speedier alternatives to the mode function?<p>I'm trying to sort through a very large matrix (12x4^12). It's actually a matrix generated by <a href = "http://www.mathworks.com/matlabcentral/fileexchange/24325-combinator-combinations-and-permutations">combinator</a> of all possible permutations with repetitions of <b>choosing 12 from 4</b> , though that's not critical to this question. What I need to do is identify all columns in which each number is repeated no more than <i>x</i> times (say <i>x</i> = 3 here). Here's simplified sample code:</p><pre class="language-matlab">x = 3;
poss = randi(4,12,4^12); % in my code: poss = combinator(4,12,'p','r')';
[M,F] = mode(poss,1);
evenposs = poss(:, F<=x );
</pre><p>My problem is that the third line above (with mode) is very slow, over 400 seconds on my computer, so it seems that doing it through the mode function is highly inefficient. Obviously I could do this with a for loop, but I've been trained to avoid that in Matlab - I thought this mode function might have been a crafty way to avoid the loop, but now I'm wondering if there are still craftier ways of achieving this.</p><p>Bonus points (i.e. my eternal gratitude) if anybody can suggest a way of using <a href = "http://www.mathworks.com/matlabcentral/fileexchange/24325-combinator-combinations-and-permutations">combinator</a> or another package to generate permutations <i>with limited repetitions</i>, so that I can avoid this filtering step entirely.</p>Shane/matlabcentral/answers/contributors/4386434-shanetag:www.mathworks.nl,2005:Question/1437772014-07-29T18:50:14Z2014-07-29T19:09:20ZError: flag=0 (initialize), at start of simulation. --> subscripted assignmetn dimension mismatch<p>Hello,</p><p>I've a simulink file to simulate an building with a PV-collector that's running correctly. When I want to the same file run for another model I got this error:
--> Error in 'Finalmodel2' while executing MATLAB S-function 'wavosimulinksfun', flag=0 (initialize), at start of simulation. --> subscripted assignmetn dimension mismatch.</p><p>I compared the m-file (Finalmodel1.m) from first model with the model that get's the error (Finalmodel2.m) but there are really no differences except some walls etc.
How can I remove this error?</p><p>Thanks in advance!
Lisan</p>Lisan/matlabcentral/answers/contributors/4551679-lisantag:www.mathworks.nl,2005:Question/1436742014-07-29T02:15:52Z2014-07-29T19:05:42Zcalling a function pdepe<p>i am using pdepe to solve a coupled PDE.</p><p>m = 0;
x = linspace(0,1,20);
t = linspace(0,2,5);</p><p>sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);</p><p>u = sol(:,:,1);</p><p>% A surface plot is often a good way to study a solution.</p><p>surf(x,t,u)</p><p>title('Numerical solution computed with 20 mesh points.')</p><p>xlabel('Distance x')</p><p>ylabel('Time t')</p><p>% A solution profile can also be illuminating.</p><p>figure</p><p>plot(x,u(end,:))</p><p>title('Solution at t = 2')</p><p>xlabel('Distance x')</p><p>ylabel('u(x,2)')</p><p>The boundary and initial conditions are saved in another two separate files files as below</p><p>function u0 = pdex1ic(x)</p><p>u0 = sin(pi*x);</p><p>function [c,f,s] = pdex1pde(x,t,u,DuDx)</p><p>c = pi^2;</p><p>f = DuDx;</p><p>s = 0;</p><p>My question is I want to plot c,f,s. How can i call them in the mail finction. I try to call like [c] = pdex1pde(x,t,u,DuDx); in the main functon but it says me undefine DuDx.?</p><p>Any help appriciated.</p><p>Thanks</p>Matt/matlabcentral/answers/contributors/4010927-matt