http://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2016-09-28T17:06:25Ztag:de.mathworks.com,2005:Question/3049232016-09-28T16:40:00Z2016-09-28T17:06:25ZConvert cell to table<p>Hi,</p><p>I have a 1 x 30 cell, A. Each element of A is a 1 x 10 double. How can I convert this to a 30 x 10 double, where each row is an element of cell A?</p><p>Any help would be appreciated! Thanks,</p><p>Sushma</p>sushma sharmahttp://de.mathworks.com/matlabcentral/profile/authors/1278006-sushma-sharmatag:de.mathworks.com,2005:Question/3048702016-09-28T13:31:44Z2016-09-28T17:06:03ZProjecting a shape parameter<p>Hello,
I have extracted some shape parameters, and at this point I would like to project each one of these to an X-Y axis.
Do you have any ideas how I could do that?
Is this the same as plotting them or it is something totally different?
Thank you</p>Perikles Gkiokashttp://de.mathworks.com/matlabcentral/profile/authors/7672484-perikles-gkiokastag:de.mathworks.com,2005:Question/3049282016-09-28T17:04:50Z2016-09-28T17:04:50ZReshaping array horizontally elementwise<p>Hi,</p><p>I have a 1 x 100 array, A. How can I reshape it so that I have a 10 x 10 double so that the first ten elements are the first row, second ten element are the second row, etc.</p><p>I tried reshape(A, [10,10]) but that arranged them down columns instead of rows. Any help would be appreciated!</p><p>Sushma</p>sushma sharmahttp://de.mathworks.com/matlabcentral/profile/authors/1278006-sushma-sharmatag:de.mathworks.com,2005:Question/3049272016-09-28T17:02:18Z2016-09-28T17:02:18ZTime stamping when audio begins to play<p>Is there a way of getting a timestamp for when you start playing audio similar to how you can get a timestamp for a Screen flip?</p><p>So far I read an audiofile in and load it using audioread and audioplayer. I want a way of noting the time that the player starts playing the file.</p><p>Any help is greatly appreciated!!!</p>Alicehttp://de.mathworks.com/matlabcentral/profile/authors/5514684-alicetag:de.mathworks.com,2005:Question/3048832016-09-28T14:26:01Z2016-09-28T16:59:46ZHow to interpret FFT output, Spectrogram and calculate Spectral centroid<p>Hi how do i interpret the FFT output, spectrogram (the figures below) and how do I calculate the spectral centroid ? The way i calculate spectral centroid is using summation(amplitude * frequency) / summation(frequency) Thanks in advance</p><img src = "/matlabcentral/answers/uploaded_files/60142/untitled.jpg"><img src = "/matlabcentral/answers/uploaded_files/60143/untitled2.jpg">crixushttp://de.mathworks.com/matlabcentral/profile/authors/5901434-crixustag:de.mathworks.com,2005:Question/3047552016-09-27T17:56:23Z2016-09-28T16:55:08Zreading text from various positions<p>I have a .txt with floats and strings I want to import. The text was created by a software logging all events within an experiment (by time), organized in trials, so it looks a bit like:</p><pre class="language-matlab">+++ LogStart1 +++
procedure = org
List = 45
Condition = 43
DelayOnset = 1
[and a lot more of variables]
+++ LogEnd +++
+++ LogStart2 +++
[and the same for the second trial and so on...]
</pre><p>I would like to get a vector of all values for each variable (e.g., "DelayOnset"). I started importing data with fscanf, lets say, "DelayOnset" was the third string in the file:</p><pre class="language-matlab">filename = 'data.txt';
fid = fopen(filename);
formatSpecDELAY = '%*s %*s DelayOnset=%f'; [here is the object I want, so skip a string and skip another string, and then the position is after "DelayOnset="]
DelayOnset= fscanf(fid,formatSpecDELAY, *1*);
</pre><p>This worked out well, but if I can't do this for each variable, because as the file contains 1000+ lines, I would have to skip each object before the actual values I want to read, that is, I would have to write %*s a thousand times. Initially I thought, if I don't limit the number of objects (1 in the example above), I get every value for delay in the file ("search for every "DelayOnset=" and return the float which follows"), but that was not the case. In fact, I had to skip all the objects between DelayOnset in the first trial and DelayOnset in the second trial in order to get a vector of both values. I can't do this for the whole file.</p><p>Is it possible to create several points of reference within the text file, in order to start fscanf from these points?</p><p>Thank you very much in advance!</p>Franz Kohlhushttp://de.mathworks.com/matlabcentral/profile/authors/8843937-franz-kohlhustag:de.mathworks.com,2005:Question/3049242016-09-28T16:43:26Z2016-09-28T16:54:57Zhow to save image on which calculation are performed?<p>img = imread('Image');
gfrgb = imfilter(img, fspecial('gaussian', 3, 3), 'symmetric', 'conv');</p><p>cform = makecform('srgb2lab', 'AdaptedWhitePoint', whitepoint('d65'));
lab = applycform(gfrgb,cform);
l = double(lab(:,:,1)); lm = mean(mean(l));
a = double(lab(:,:,2)); am = mean(mean(a));
b = double(lab(:,:,3)); bm = mean(mean(b));
sm = (l-lm).^1.7 + (a-am).^3.5 + (b-bm).^0.8;
imshow(sm,[]);</p><p>how to save resultant image in ?</p><p>also gbvs images with this syntax
show_imgnmap( img2 , map);</p>Hash irhttp://de.mathworks.com/matlabcentral/profile/authors/8853028-hash-irtag:de.mathworks.com,2005:Question/3049082016-09-28T15:51:45Z2016-09-28T16:50:52ZFix help text for newer MATLAB versions<p>I've noticed a change in MATLAB's response to help text. We have equipment that, in the event of an error, automatically generates a trace of internal variables, and creates a MATLAB-formated file that includes help text identifying the machine name, firmware versions and timestamp of the error. We then have scripts that parse the help text and data to generate a human-readable report. We had been using R2010bSP1 for years, but when we updated we find the help() function returns differently. I've tested R2015b and R2016a, below is an example of the change:</p><p>data.m:</p><pre class="language-matlab">% Date: Tuesday, September 27, 2016 10:21:14 AM
% Arm B: 0.0.0.3
% Arm M: 2.1.15.8
% FPGA: 86.73.0.0
% Rows: 2048
</pre><pre> 24 865589 1141503331
25 865589 1112790400
26 865589 1143725291
27 865589 -1002890685
:</pre><p>2010bSP1:</p><pre class="language-matlab">>> load 'data.m';
>> help('data.m')
Date: Tuesday, September 27, 2016 10:21:14 AM
Arm B: 0.0.0.3
Arm M: 2.1.15.8
FPGA: 86.73.0.0
Rows: 2048
</pre><pre class="language-matlab">>>
</pre><p>R2015b and R2016a:</p><pre class="language-matlab">>> load 'data.m';
>> help('data.m')
data is a variable of type doub.
</pre><pre class="language-matlab">>> help(data)
Struct contents reference from a non-struct array object.
</pre><pre class="language-matlab">>>
</pre><p>Would appreciate any suggestions on how to modify the help() function call to return the help text as before when using newer versions of MATLAB.</p><p>Thanks!</p>Jon Northuphttp://de.mathworks.com/matlabcentral/profile/authors/2925141-jon-northuptag:de.mathworks.com,2005:Question/3049262016-09-28T16:48:03Z2016-09-28T16:48:03ZHow to design a RL load for 1000 watt output power of single phase inverter?<p>I am designing a Z source inverter with output power to be around 1Kwatt I am planning to use an RL load for the same. However I cannot decide the value of RL load to give me required output power. Help me whether I am designing properly or share the designing steps!</p>Mrudul Mhttp://de.mathworks.com/matlabcentral/profile/authors/8480378-mrudul-mtag:de.mathworks.com,2005:Question/3049222016-09-28T16:38:50Z2016-09-28T16:45:54Zhow extract text from an image containing hindi and english characters , using OCR?<img src = "/matlabcentral/answers/uploaded_files/60158/avi.jpg">achint kaurhttp://de.mathworks.com/matlabcentral/profile/authors/8851383-achint-kaurtag:de.mathworks.com,2005:Question/3049252016-09-28T16:43:44Z2016-09-28T16:44:45ZHas anyone got an interface for Thorlab's Kinesis software?<p>Hello,</p><p>Has anyone succeeded in interfacing with the ThorLabs Kinesis software for linear stage controllers? I have so far only managed to talk to the APT ActiveX interface, but it's pretty horrible and hard-crashes MATLAB when it gets angry.</p><p>Thanks</p>Rob Campbellhttp://de.mathworks.com/matlabcentral/profile/authors/1739148-rob-campbelltag:de.mathworks.com,2005:Question/3049162016-09-28T16:22:19Z2016-09-28T16:43:31ZNeed help with computing an approximation of a singular integral.<p>Hey guys,</p><p>I'm fairly new at Matlab but would like to use it to compute the integral from [0,infinity):
(sin(x^5)) / (x^(2)*(1+x)^(55)) dx</p><p>I was going to use the Gauss quadrature but that only works for polynomials, hence i'm not entirely sure as to what method or technique I can use in this case. Any ideas?</p><p>Thanks a lot</p>Lorenzo Wagemakerhttp://de.mathworks.com/matlabcentral/profile/authors/8850505-lorenzo-wagemakertag:de.mathworks.com,2005:Question/3049172016-09-28T16:25:05Z2016-09-28T16:43:30ZCos Magnitude changing for unknown reasons<p>This is probably not mat labs fault but i don't understand why my magnitude is changing</p><p>If i plot</p><p>.5*cos(x)</p><p>no surprise my min and max magnitude of the function is -.5 and plus .5</p><p>if i plot</p><p>.5*cos(2*pi*60*x)</p><p>My min max magnitude is changing from -.4 to .5
Why am i loosing .1 on the bottom just by changing the frequency</p>Roberthttp://de.mathworks.com/matlabcentral/profile/authors/2986565-roberttag:de.mathworks.com,2005:Question/3047992016-09-28T00:36:12Z2016-09-28T16:42:16ZThis is code for Modified Regula Falsi method for finding roots. Something in here is preventing the if statements from executing properly. <pre class="language-matlab">function ModRegFal = ModRegFal(a, b, n)
</pre><pre class="language-matlab">format long;
</pre><pre class="language-matlab">a = input('Enter a value for lower boundary a: ');
b = input('Enter a value for upper boundary b: ');
n = input('How small should should the error be (to what -power)? ');
</pre><pre class="language-matlab">if (f(a)*f(b) > 0 )
disp ('Invalid values of a and b. Program Closing')
return;
end;
</pre><pre class="language-matlab">F = f(a);
G = f(b);
w0 = a;
</pre><pre class="language-matlab">while (1)
wn = (G*a-F*b)/(G-F);
disp([a b wn w0]) %% just checking where the values are, and it they look correct
if f(a)*f(wn) > 0
disp('ranif 1')%% just checking where the values are, and it they look correct
b = wn;
G = f(wn);
if f(w0)*f(wn) > 0
F = F/ 2; end;
disp('ranif 2')%% just checking where the values are, and it they look correct
disp([a b wn w0])%% just checking where the values are, and it they look correct
else
a = wn;
F = f(wn);
if f(w0)*f(wn) > 0
disp('ranif 3')%% just checking where the values are, and it they look correct
disp([a b wn w0])%% just checking where the values are, and it they look correct
G = G/ 2; end;
end
disp([a b wn w0])
if (abs((wn - w0)/wn) < 0.5*10^-n)
disp ('The root is: ')
disp (wn)
break;
else
w0 = wn;
end
</pre><pre class="language-matlab">end
</pre><p>I wrote a separate scrip with the function y = f(x)
y = x^2 - 2;</p>Jay Gerstenhttp://de.mathworks.com/matlabcentral/profile/authors/6834268-jay-gerstentag:de.mathworks.com,2005:Question/3048112016-09-28T04:10:05Z2016-09-28T16:40:09ZHow to use one GUI to call many other GUI<p>Hi, I'm trying to create a main GUI that gives options to user. Each options when pressed will lead users to another GUI. I only managed to do this when there is only 1 option in the main GUI using this simple code:</p><pre class="language-matlab">pushbutton1_Callback(option1);
option1;
</pre><p>However when i try to add more options to my main GUI it doesn't work. Below is the code:</p><pre class="language-matlab">pushbutton1_Callback(option1);
option1;
pushbutton2_Callback(option2);
option2;
pushbutton3_Callback(option3);
option3;
</pre><p>Using the above code, when pushbutton1 and pushbutton2 is pressed nothing happens. When pushbutton3 is pressed, all GUI for option1, option2, and option3 open in a infinite loop.</p><p>Hope if anyone have a solution to this. Thanks</p>Aloysius Pallishttp://de.mathworks.com/matlabcentral/profile/authors/7439499-aloysius-pallistag:de.mathworks.com,2005:Question/3049212016-09-28T16:37:56Z2016-09-28T16:38:32ZHow can I define one phi transformation on nlmefit matlab command<p>Hello! I want implement a Nonlinear mixed-effects model using the nlmefit command.
The response is given by the equation:
phi(1)*exp(-phi(2)*exp(phi(3)*t)).
My problem is that I do not know how to define the vector phi. phi(1), phi(2) and phi(3) are polynomials of the individual chacteristics. Example: phi(1)= 1.5*Age^2 + 3.2*Weight^3
Thank very much</p>André Filipe Abreuhttp://de.mathworks.com/matlabcentral/profile/authors/8362940-andre-filipe-abreutag:de.mathworks.com,2005:Question/3049202016-09-28T16:36:01Z2016-09-28T16:36:01Zi want to convert the image containing two languages into english.<img src = "/matlabcentral/answers/uploaded_files/60157/ach1.jpg">achint kaurhttp://de.mathworks.com/matlabcentral/profile/authors/8851383-achint-kaurtag:de.mathworks.com,2005:Question/3047732016-09-27T19:18:12Z2016-09-28T16:35:48ZHow can i compress the text file using huffman encoding?<p>Hi</p><p>I am using a text file to hide inside an image file in lsb plane.
But i want to compress the text file using huffman encoding and hide inside the lsb plane of image file.
After retrieve the text file, the text file should be decompressed using huffman encoding.</p><p>Can you help in this matter.</p>Sanjeeb Beherahttp://de.mathworks.com/matlabcentral/profile/authors/8566904-sanjeeb-beheratag:de.mathworks.com,2005:Question/3049132016-09-28T15:59:55Z2016-09-28T16:34:54ZColor Space Change from RGB to CHL<p>I would like to change the RGB image I am using, to Chroma, Hue, and lightness
how can I do so?</p>Ahmed El Sheikhhttp://de.mathworks.com/matlabcentral/profile/authors/7976918-ahmed-el-sheikhtag:de.mathworks.com,2005:Question/3049192016-09-28T16:34:14Z2016-09-28T16:34:14Zhow to extract text from an image that contains hindi and english languages?<img src = "/matlabcentral/answers/uploaded_files/60156/8aecbf7579c12a0c7bea6312ad84d349.jpg">achint kaurhttp://de.mathworks.com/matlabcentral/profile/authors/8851383-achint-kaurtag:de.mathworks.com,2005:Question/1509562014-08-15T06:51:34Z2016-09-28T16:34:12ZPlotting matrix-skewed ellipses<p>Hello,
I am trying to plot the unit circle and then applying a 2x2 matrix on this circle to skew it. The column vector x is defined as x = [x1; x2], where x1 and x2 are cos(θ) and sin(θ), respectively, and θ ∈ [0,2π). I have generated 1000 vectors equidistant between 0 and 2π and created the unit circle. The issue I have is when I attempt to apply the matrices. The code I have so far is below:</p><pre class="language-matlab">clear all
close all
clc
</pre><pre class="language-matlab">t=linspace(0,2*pi,1000);
x1=cos(t);
x2=sin(t);
x=[x1;x2];
</pre><pre class="language-matlab">plot(x1,x2);
------------
</pre><pre class="language-matlab">A1=[2 0;0 3];
plot(A1*x);
</pre><pre class="language-matlab">A2=[1 2;3 4];
plot(A2*x);
</pre><pre class="language-matlab">A3=[1 2;2 4];
plot(A3*x);
</pre><p>The code above the line correctly produces the unit circle. The rest of the code should skew the unit circle into an ellipse but I get a mess when trying to plot.</p><p>Thanks!</p>Nicolashttp://de.mathworks.com/matlabcentral/profile/authors/5511840-nicolastag:de.mathworks.com,2005:Question/3048212016-09-28T06:45:57Z2016-09-28T16:32:51ZSaving edit toolbox into mat file<p>After extracting the features of an image. The result will be appear in the edit toolbox.I want to happen now is, I want to save it as mat file but in one column only. Please help me!</p><img src = "/matlabcentral/answers/uploaded_files/60106/Untitled.png">Hazel Sialongohttp://de.mathworks.com/matlabcentral/profile/authors/8658383-hazel-sialongotag:de.mathworks.com,2005:Question/3049182016-09-28T16:32:37Z2016-09-28T16:32:37Zauxiliary variable for mixed integer programming<p>I have to write this inequality constraint with auxiliary variable(in this case x(i,h,t)) for "intlinprog"</p><p>y(i,t)>=x(i,h,t)-x(i,h,t+1) for each h=1:n_rack, i=1:n:client, t=1:n_time-1</p><p>x(i,h,t) e y(i,t) are both binary and y is the only variable in objective function</p><p>Thanks a lot, Marco</p>Marco Nardecchiahttp://de.mathworks.com/matlabcentral/profile/authors/7849718-marco-nardecchiatag:de.mathworks.com,2005:Question/3048352016-09-28T08:51:04Z2016-09-28T16:31:41Zgui error: Struct contents reference from a non-struct array object<p>I have a drop down list in my GUI. it consists of 5 axes, from which one main axes displays my selected image. I want to select the image from the drop list and it should be displayed in the first axes for further processing. At first when I was working on my GUI, this worked. But don't know how come this error appeared just when I run my GUI now.</p><p>the error is just on this very first statement of the callback:</p><pre class="language-matlab">axes(handles.axes1);
</pre><p>Error:</p><pre class="language-matlab">Struct contents reference from a non-struct array object.
</pre><p>I can't figure out my mistake. Help needed.</p>Ria3242http://de.mathworks.com/matlabcentral/profile/authors/6743432-ria3242tag:de.mathworks.com,2005:Question/3047742016-09-27T19:26:33Z2016-09-28T16:30:25ZConverting a std::vector<float> to mxArray using ocvMxArrayFromVector<p>Hello,</p><p>I'm currently working with mex matlab and OpenCV libraries. I'm using the results of the computation of HOG features, which is of type std::vector<float>, and need it as an output of the mex function.</p><p>I'm therefore trying to use the ocvMxArrayFromVector function, which is supposed to conver a vector of a given type to the required mxArray data type output.</p><p>The part of code I'm using is:</p><pre class="language-matlab">vector<float> descriptorValues(outDim);
hog->compute(croppedImg, descriptorValues, Size(0,0), Size(0,0), locations);
plhs[0] = ocvMxArrayFromVector(descriptorValues);
</pre><p>But when compiling it returns the following error:</p><pre class="language-matlab">Error using mexOpenCV (line 122)
/tmp/mex_1394440023880_2588/HOGDescriptorOCV.o: In function `computeHOGFeatures(int, mxArray_tag**, mxArray_tag
const**)':
HOGDescriptorOCV.cpp:(.text+0xb24): undefined reference to `ocvMxArrayFromVector(std::vector<float,
std::allocator<float> > const&)'
collect2: error: ld returned 1 exit status
</pre><p>I'm compiling using g++ on an Ubuntu, matlab version R2016b.</p><p>I would be very thankful for your help.</p><p>David</p>David Morenohttp://de.mathworks.com/matlabcentral/profile/authors/8789106-david-morenotag:de.mathworks.com,2005:Question/3049112016-09-28T15:56:39Z2016-09-28T16:29:05ZHow can I set a colorbar for single values corresponding to multiple polygons created with geoshape?<p>I am trying to create a map similar to the one below, except each polygon needs to be colored corresponding to a single value.</p><p><a href = "http://imgur.com/a/sO5GA">http://imgur.com/a/sO5GA</a></p><p>So far, I have created the polygons and included sample values in the structures. Is there a way to create a colorbar for each polygon facecolor corresponding to each 'sampleNum'?</p><p>Sample code:</p><pre class="language-matlab">latZone1 = [25, 25, 50, 50, 25];
lonZone1 = [-105, -125, -125, -105, -105];
zone1Poly = geoshape(latZone1, lonZone1, 'sampleNum', 89);
zone1Poly.Geometry = 'polygon';
</pre><pre class="language-matlab">latZone2 = [25, 25, 40, 40, 25];
lonZone2 = [-100, -105, -105, -100, -100];
zone2Poly = geoshape(latZone2, lonZone2, 'sampleNum', 63);
zone2Poly.Geometry = 'polygon';
</pre><pre class="language-matlab">latZone3 = [40, 40, 50, 50, 40];
lonZone3 = [-100, -105, -105, -100, -100];
zone3Poly = geoshape(latZone3, lonZone3, 'sampleNum', 45);
zone3Poly.Geometry = 'polygon';
</pre><pre class="language-matlab">latZone4 = [25, 25, 35, 35, 25];
lonZone4 = [-95, -100, -100, -95, -95];
zone4Poly = geoshape(latZone4, lonZone4, 'sampleNum', 78);
zone4Poly.Geometry = 'polygon';
</pre><pre class="language-matlab">latZone5 = [35, 35, 40, 40, 35];
lonZone5 = [-95, -100, -100, -95, -95];
zone5Poly = geoshape(latZone5, lonZone5, 'sampleNum', 70);
zone5Poly.Geometry = 'polygon';
</pre><pre class="language-matlab">latZone6 = [40, 40, 50, 50, 40];
lonZone6 = [-95, -100, -100, -95, -95];
zone6Poly = geoshape(latZone6, lonZone6, 'sampleNum', 25);
zone6Poly.Geometry = 'polygon';
</pre><pre class="language-matlab">states = geoshape(shaperead('usastatehi', 'UseGeoCoords', true));
figure('Visible','on');
hold on
ax = usamap([25 50],[-125 -65]);
geoshow(states,'FaceColor', 'w')
geoshow(zone2Poly, 'LineWidth', 1,'FaceColor','k')
geoshow(zone1Poly, 'LineWidth', 1,'FaceColor','r')
geoshow(zone3Poly, 'LineWidth', 1,'FaceColor','b')
geoshow(zone4Poly, 'LineWidth', 1,'FaceColor','b')
geoshow(zone5Poly, 'LineWidth', 1,'FaceColor','r')
geoshow(zone6Poly, 'LineWidth', 1,'FaceColor','g')
</pre><p>Any help is greatly appreciated!</p>AMarthttp://de.mathworks.com/matlabcentral/profile/authors/4731622-amarttag:de.mathworks.com,2005:Question/3048132016-09-28T05:19:13Z2016-09-28T16:24:20Zhow to recognize the alphabets from braille code<p>hi ..
I want to translate the braille code to text in English. I have attached two images. One image is reference image & another one is processed image in which I have pre-processed and drawn grid lines for each letter(braille). Now my aim to recognize each grid box. Each box contains one alphabet.</p>Hasini http://de.mathworks.com/matlabcentral/profile/authors/8590085-hasinitag:de.mathworks.com,2005:Question/3048462016-09-28T10:26:15Z2016-09-28T16:21:42ZReplace a missing string in a table<p>I want to replace all missing strings in a table with a string of my choice, say 'unknown'. I use R2016a (without an upgrade option), so functions like <i>fillmissing</i> are not available to me, in case they could be of help. Eg:</p><pre> dblVar = [NaN; 3; 7; 9];
cellstrVar = {'one'; 'three'; ''; 'nine'};
categoryVar = categorical({''; 'red'; 'yellow'; 'blue'});
A = table(dblVar, cellstrVar, categoryVar)
A =
dblVar cellstrVar categoryVar
______ __________ ___________</pre><pre> NaN 'one' <undefined>
3 'three' red
7 '' yellow
9 'nine' blue </pre><p>I would like to end up with this:</p><pre> A =
dblVar cellstrVar categoryVar
______ __________ ___________</pre><pre> NaN 'one' unknown
3 'three' red
7 'unknown' yellow
9 'nine' blue </pre><p>Note I also replaced the categorical '<undefined>' as well, if you can please include in your answer.</p><p>Is there a way to do this <i>without</i> changing A's structure, eg from table to cell, in the process? The reason I want to avoid the transformation is my table is large, and transformation may cause memory issues.</p><p>Edit to add: the location of the missing string value has to be identified as well, there may be several such columns in the table.</p><p>Many thanks.</p>Orestis Chrysafishttp://de.mathworks.com/matlabcentral/profile/authors/8725420-orestis-chrysafistag:de.mathworks.com,2005:Question/3048662016-09-28T13:17:08Z2016-09-28T16:17:32ZHow can I open multiple URL present in a table on a website?<p>Hi all. I need a code to open all the individual URLs present in the serial numbers on the table of this page: <a href = "http://www.voltstats.net/">http://www.voltstats.net/</a> I was thinking of using the webread function, yet I do not know how to actually open the links. HELP?!</p>Giuliohttp://de.mathworks.com/matlabcentral/profile/authors/8830152-giuliotag:de.mathworks.com,2005:Question/3049142016-09-28T16:08:46Z2016-09-28T16:16:45ZWrite a function with one input integer argument that returns an output matrix(MQ) which is a 2n by 2n matrix. MQ consist of 4 n-by-n submatrices top left are all ones top right corner are all 2's bottom left are 3's and bottom right are 4's<p>function [MQ] = myquadrants(n)
I don't know how to set up the matrix</p>Khalid Tewfikhttp://de.mathworks.com/matlabcentral/profile/authors/8569425-khalid-tewfiktag:de.mathworks.com,2005:Question/3048692016-09-28T13:29:43Z2016-09-28T16:13:33Zpushbutton in gui for space bar<p>I am creating a mouse controlled virtual keyboard using pushbuttons in gui.but cant create callback code for space bar.please help.
my code for space bar:</p><pre class="language-matlab">function space_Callback(hObject, eventdata, handles)
</pre><pre class="language-matlab">% hObject handle to space (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring=get(handles.text1,'string');
set(handles.text1,'string',sprintf('%s %s',OLDstring,' '));
</pre><p>this creates space in static text but after i press another keybutton for input...the space is gone and the inputs are displayed without the space..
..code for other input...example:for entering h:</p><pre> function h_Callback(hObject, eventdata, handles)
% hObject handle to h (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring=get(handles.text1,'string');
NEWstring=('h');
textstring=strcat(OLDstring,NEWstring);
set(handles.text1,'string',textstring);</pre>Shreyas Kagalkarhttp://de.mathworks.com/matlabcentral/profile/authors/8851347-shreyas-kagalkartag:de.mathworks.com,2005:Question/3037272016-09-20T10:07:34Z2016-09-28T16:12:18ZFMCW sweeptime Query!<p>I am working on fmcw radar with these parameters :</p><pre class="language-matlab">end
</pre><p>Kindly help me through this query, awaiting reply</p>Hassam Mahmoodhttp://de.mathworks.com/matlabcentral/profile/authors/4301207-hassam-mahmoodtag:de.mathworks.com,2005:Question/3049152016-09-28T16:12:06Z2016-09-28T16:12:49ZParfor thinks variable is a file<p>Dear all,</p><p>I have a problem using parfor that I am having difficulty isolating/recreating. The software is complex, so I have a representative example of what is happening but cannot post the full code.</p><pre class="language-matlab">function processedData = getProcessedData( inputData, extraData )
</pre><pre class="language-matlab">numberEntries = length( inputData );
tempVariable = cell( numberEntries, 1 );
</pre><pre class="language-matlab">parfor ii = 1:numberEntries
tempVariable{ii} = processSingleDataEntry( inputData(ii), extraData );
end
</pre><pre class="language-matlab">% Post-process entries in tempVariable to get processedData
</pre><p>The function processSingleDataEntry() is in the MATLAB path and, when not using the parfor loop, does not return any errors. The length of the output from processSingleDataEntry() varies with the inputData(ii). See post <a href = "https://www.mathworks.com/matlabcentral/answers/180460-parfor-loop-and-variable-length-output">here</a> for my motivation for this method. I then assemble the output in the post-processing step.</p><p>The error I get is then (with edits for the example):</p><pre class="language-matlab">Error using getProcessedData (line 5)
An UndefinedFunction error was thrown on the workers for 'tempVariable'. This might be
because the file containing 'tempVariable' is not accessible on the workers. Use
addAttachedFiles(pool, files) to specify the required files to be attached. See the
documentation for 'parallel.Pool/addAttachedFiles' for more details.
</pre><pre class="language-matlab">Caused by:
Undefined function or variable 'tempVariable'.
</pre><p>I made sure the variable is not misspelled in the actual code (used copy/paste of variable name). To make matters worse, I have two different data sets used to define inputData, and I only get this error with one of them. All code runs correctly if I change the parfor-loop to a for-loop.</p><p>After setting a breakpoint in MATLAB's attachDependentFilesToPool.m, it does seem to think that tempVariable is a file for the case where it fails. The case that succeeds does not attempt to look for a file. I have been unable to find where MATLAB decides tempVariable is a file that needs to be attached.</p><p>Any advice would be greatly appreciated.</p><p>Sincerely,</p><p>Brandon</p>Brandon Joneshttp://de.mathworks.com/matlabcentral/profile/authors/8852431-brandon-jonestag:de.mathworks.com,2005:Question/3039072016-09-21T15:00:17Z2016-09-28T16:07:56ZHow can I create a polar plot from 2d matrix<p>Hi all,
I have measured the thickness of the liquid around the pipe at different angles (60 measurement points circumferentially). Therefore I have 60x1 matrix. My question is: how can I draw a polar plot showing the variation of the thickness around the pipe (at 60 points). The pipe diameter is 125 mm and we are only interested in drawing the thickness variations around the wall of the pipe.
Any suggestions please?
Regards</p>abuhttp://de.mathworks.com/matlabcentral/profile/authors/5201139-abutag:de.mathworks.com,2005:Question/3045962016-09-26T17:21:56Z2016-09-28T16:07:02ZI'm trying to create a time varying system in simulink using matlab function block but even if the logic is correct it says the value which i'm calling form workspace is not Simulink.Signal <p>function y = fcn
%#codegen
for i=1:1:100
U_b(:,i)=x_storage(14,i)-(K(1,:,i)'*(X_bar(i,:)'));
end
y = U_b;</p><p>K,x_storage, X_bar comes from workspace and i've changed the data type to data store memory
I tried to use the input option also it did not work out.
X_bar is a syms data type</p>sabyasachi Neogihttp://de.mathworks.com/matlabcentral/profile/authors/7460471-sabyasachi-neogitag:de.mathworks.com,2005:Question/3049122016-09-28T15:58:41Z2016-09-28T16:06:06ZMatching data and time with sample number<p>Hi all, i have a data for 24hrs with sampling frequency of fs= 500Hz (so t=1/fs:1/fs:1/fs*length(data)). Now i want to extract the data from a particular time. For example the start time of the data is "11/19/2015 18:00" and i want to find the point in "t" at "11/20/2015 6:34".Can someone please help me with this? I am new to Matlab and not sure how to use datevectors.</p>Sowmya MRhttp://de.mathworks.com/matlabcentral/profile/authors/6380289-sowmya-mrtag:de.mathworks.com,2005:Question/3049102016-09-28T15:54:46Z2016-09-28T16:05:30ZHOW TO PLOT MULTIPLE LINE GRAPH<p>PLEASE HOW CAN I TO PLOT LINE GRAPH WITH VALUES OF (BAUCHI,KADUNA,JOS,LAGOS,ENUGU,PORT HARCOURT ON THE Y AXIS) AND (THE MONTHS ON THE X AXIS) TITLE OF Y AXIS IS “attenuation level(dB)” AND TITLE OF X AXIS “MONTHS”</p>hassan USMANhttp://de.mathworks.com/matlabcentral/profile/authors/8351765-hassan-usmantag:de.mathworks.com,2005:Question/3047672016-09-27T18:47:24Z2016-09-28T16:02:33ZFind string that has multiple substrings<p>I have a cell array each cell containing a string and I am trying to find all cells that have contain 2 substrings. For example</p><pre class="language-matlab">A = [Car is fast; Car is slow; Train is fast; Plane is fast]
</pre><p>I am new to cellfun (that doesn't necessarily have to be the solution) but figured that was the only way to do it.</p><pre class="language-matlab">any(~cellfun('isempty',strfind(A,'Car' 'fast')))
</pre><p>The result should be</p><pre class="language-matlab">[1;0;0;0]
</pre>Tyler Murrayhttp://de.mathworks.com/matlabcentral/profile/authors/8637352-tyler-murraytag:de.mathworks.com,2005:Question/3048092016-09-28T03:48:57Z2016-09-28T16:01:38ZExtract variable in nested for loop that otherwise gets replaced <p>I have several for loops that look something like this</p><pre class="language-matlab">p=rand(....)
h=rand(....)
for i:100
HCPV(i)=p(i)*h(i)
n=29
for j=1:n
cum_CO2inj(j)=function(p(i), HCPV(i),j) %I simplify here this is not actually the full code
%I want to generate/save cum_CO2inj here (which is a vector of length 30) for every iteration of i (outer most loop)?
end
end
</pre><p>cum_CO2inj otherwise just rewrites it self every time we iterate over i - instead I would like to see the output of 100 cum_CO2inj vectors of size 30 or a matrix of size 100 by 30?
Can anyone help me with this please?</p>CKhttp://de.mathworks.com/matlabcentral/profile/authors/2727484-cktag:de.mathworks.com,2005:Question/3049072016-09-28T15:50:52Z2016-09-28T15:59:55ZHigher order matrix multiplication/Parallel for loops error - variable cannot be classified<p>Hi,</p><p>I have M data points (M=1e6) and N 2-by-2 matrices (N=100).</p><p>I have defined a 2-by-2-by-N-by-M array.</p><p>What is the most efficient way to multiply those N 2-by-2 matrices (algebraically), for each data point?</p><p>I know a nested for-loop works, of course, but it takes too long for those N,M values.</p><p>Another approach I tried was to use parfor:</p><pre class="language-matlab">T=rand(2,2,N,M);
A=zeros(2,2,M);
parfor m=1:M
for n=1:(N-1)
if n==1
T_tot = T(:,:,n,m);
continue;
end
T_tot = T(:,:,n,m)*T_tot;
A(:,:,k) = T_tot
end
end
</pre><p>But I get the following error:</p><p>Error: The variable A in a parfor cannot be classified.</p><p>Any help would be greatly appreciated.
Thanks!</p>Yanir Schwartzhttp://de.mathworks.com/matlabcentral/profile/authors/7999411-yanir-schwartztag:de.mathworks.com,2005:Question/3044632016-09-26T00:48:37Z2016-09-28T15:57:35ZUsing quiver to plot a given flow field equation<p>I have two equations I would like to plot. I am having trouble understanding the application of the quiver command. The examples that I have found do indeed plot flow fields but they lack the relations from which the numbers are taken. Could someone help me apply matlab to plot these two attached equations?</p>Alejandro Monreal-Alvarezhttp://de.mathworks.com/matlabcentral/profile/authors/8548314-alejandro-monreal-alvareztag:de.mathworks.com,2005:Question/3049042016-09-28T15:43:52Z2016-09-28T15:57:25ZHow to get the value of the the byte 6 (for example) from an unknown file which you can't open<p>This file is supposed to be an image, of 256x256 pixels where 1 byte of the file is 1 pixel of the array of the image</p>Victor Gonzalezhttp://de.mathworks.com/matlabcentral/profile/authors/8851986-victor-gonzaleztag:de.mathworks.com,2005:Question/3044752016-09-26T02:42:10Z2016-09-28T15:57:22ZHow would i create the dirac delta function and plot graphs of the following functions ?<p>The attached picture shows 4 limiting forms of the dirac delta function. I am not sure how to put this into matlab can anyone show me or guide me in the right direction?</p>Neo http://de.mathworks.com/matlabcentral/profile/authors/6726749-neotag:de.mathworks.com,2005:Question/3049092016-09-28T15:54:49Z2016-09-28T15:54:49ZSimulink System Object Property - Variable sized properties in handle classes are not supported<p>Hi All</p><p>I have a Simulink System Object for which I created several properties. I set some of the properties in the constructor method and the model runs fine in Interpreted Mode. When I try to run in Code Generation mode I get the following error:</p><pre class="language-matlab">Variable sized properties in handle classes are not supported
</pre><pre class="language-matlab">This operation defines 'example.s' as unknown.'.
</pre><p>I am not sure where to start even. Any ideas will be appreciated.</p><p>Regards</p><p>Etienne</p>Etienne Coetzeehttp://de.mathworks.com/matlabcentral/profile/authors/1541964-etienne-coetzeetag:de.mathworks.com,2005:Question/524232012-10-31T18:06:11Z2016-09-28T15:53:41ZRun scripts in parallel on multiple workers (distributed job)<p>Hello, I have 12 workers available in my local matlabpool. I'd like to run 3 scripts (doing different simulink simulations) in parallel on those workers.
There is no need for those tasks to communicate to each other.
What is the best way to go about this (programmatically)?</p><pre> matlabpool;
pctRunOnAll('cd C:\Users\Controls\prj\sunapee');
pctRunOnAll('startup');
pctRunOnAll('sys = ''sunapee'';')
pctRunOnAll('load_system( sys)');
low_j = batch('low_pressure_tsts');
med_j = batch('mid_pressure_tsts');
hi_j = batch('high_pressure_tsts');</pre><p>Doesn't seem to be doing the trick.
Thank you,
Igor</p>Igor Bravermanhttp://de.mathworks.com/matlabcentral/profile/authors/2526371-igor-bravermantag:de.mathworks.com,2005:Question/3049052016-09-28T15:43:40Z2016-09-28T15:53:41ZTrouble plotting a function involving matrices as a line graph<p>This is a bit of a useless function, I realise, but it is part of a larger function I am having trouble plotting and I'd appreciate some help.</p><pre class="language-matlab">function f = f(x)
sig = [1 0;0 1];
M = sig.*x + sig;
f = trace(M);
end
</pre><p>I see no reason why you shouldn't be able to plot it as a line graph, but every way I try to plot the graph I get errors based on multiplying matrices of different sizes.</p><p>Can anyone advise me a way you could plot this function in matlab, say between x = 0 and x = 3, in the form given (I know it seems silly and that there are much quicker and simpler ways to do what this function does such as</p><pre class="language-matlab">function g = g(x)
g = 2.*x + 2
</pre><p>but that's not the point, doing it as I've written using matrices will be very helpful to me as part of the larger function and that's where my problem lies!!)</p>T Phttp://de.mathworks.com/matlabcentral/profile/authors/8321365-t-ptag:de.mathworks.com,2005:Question/3049032016-09-28T15:36:26Z2016-09-28T15:51:21ZPlotting Cos complete stupidity<p>I have been plotting trig functions like this for years in matlab with zero problem
Now all of a sudden it no longer works.</p><pre class="language-matlab">x = [0:.1:20]
y = .5*cos(2*pi*60.*x)
plot(x,y)
</pre><p>Now today all i get is a constant value.
What is going on here</p><p>Doing the following makes no difference</p><pre class="language-matlab">x = [0:.1:20]
plot(x,.5*cos(2*pi*60.*x))
</pre><p>Someone please tell me why in the holy land of matlab multiplying the vector X by a constant of 2*pi*60 completely ruins the plot and turns it into a constant.
It makes zero sense!</p><p>but yet somehow this works</p><pre class="language-matlab">plot(x,cos(x))
</pre><p>All I'm doing is multiplying the foreign X by a constant of 2*pi*60
This is ridiculous</p><p>Also just to add
the following works</p><p>y = cos(2*x)
y = cos(2*pi*x)</p><p>But for some insane reason the plot goes nuts when you plot</p><p>y = cos(2*pi*60*x) and says the plot is a constant .5</p><p>Also just to add to the infuriation of this if you plot</p><pre class="language-matlab">plot(x,.5*cos(120*pi*x)) %you get a constant of .5
plot(x,.5*cos(119*pi*x)) %you get a proper oscillating cos
</pre>Roberthttp://de.mathworks.com/matlabcentral/profile/authors/2986565-roberttag:de.mathworks.com,2005:Question/3048842016-09-28T14:33:35Z2016-09-28T15:48:36ZMatrix from triple loop<p>I am trying to simplify the code from following loop:</p><pre class="language-matlab">for i = 1:10
for j = 11:20
RS_1(:,i) = signal(:,i) - signal(:,j);
end
for j = 21:30
RS_2(:,i) = signal(:,i) - signal(:,j);
end
for j = 31:40
RS_3(:,i) = signal(:,i) - signal(:,j);
end
for j = 41:50
RS_4(:,i) = signal(:,i) - signal(:,j);
end
RS = [RS_1 RS_2 RS_3 RS_4];
end
</pre><p>With this one:</p><pre class="language-matlab">for i = 1:10
for j = 11:50
for k = 1:40
RS(:,k) = signal(:,i) - signal(:,j);
end
end
end
</pre><p>I am wondering why do I get different matrix RS?</p>cniv_wehttp://de.mathworks.com/matlabcentral/profile/authors/8354335-cniv_wetag:de.mathworks.com,2005:Question/3048912016-09-28T14:50:17Z2016-09-28T15:48:26ZIn order to generate vertical coverage plots or blake charts using radarvcp the frequency limit is 10 Ghz . I need to make plots at 16 Ghz. I can't determine what function is generating the error message about exceeding the 10 Ghz limit. Help?<p>Has anyone created blake charts or vertical coverage plots above the 10Ghz limit. If so, how?</p>Eric Morganhttp://de.mathworks.com/matlabcentral/profile/authors/8745298-eric-morgantag:de.mathworks.com,2005:Question/3048992016-09-28T15:30:27Z2016-09-28T15:47:26Zhow to plot with different distance on vertical axis<p>Hi guys , i have a vector x and a vector y.
i want to plot(x,y) but i want : in vertical axis ,the distance from value: 0 to value: 10 is as long as the distance from value: 11 to value: 100 .
I don't know how i can do that .
Can you help me ? .Thank you very much !</p><img src = "/matlabcentral/answers/uploaded_files/60150/Untitled.png">Pham Duy Hoanhttp://de.mathworks.com/matlabcentral/profile/authors/8470442-pham-duy-hoan