https://jp.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-03-26T17:00:18Ztag:jp.mathworks.com,2005:Question/3319902017-03-26T14:48:23Z2017-03-26T17:00:18ZHello! I'm having problems with the Matlab slider.<p>I have a gui with two images and a slider for manual threshold, if the image is magnified, when moving the slider it returns to the default zoom, I wish it did not happen.</p>Denilsonhttps://jp.mathworks.com/matlabcentral/profile/authors/5901095-denilsontag:jp.mathworks.com,2005:Question/3319822017-03-26T14:04:37Z2017-03-26T16:57:00Zlooping with certain condition<p>Hi,
Supposed I have two matrices A and B.
A = size 443823 x 1 and B = size 870 x1</p><p>Sample data of Matrix A =
A =[1
1
1 (n of times)…
2
2
2(m of times)
3
3
3 (p of times)
Until the end.</p><p>And sample data in Matrix B =
B = [180
182
185
189
150 .....
Till the end].</p><p>From above matrix, I would like to assign value from B depends on A in
new Matrix C, result as follow-
c =[180
180
180 (n times)
182
182 (m times)
185
185 (p times)
189
189
189
189 (... times]</p><p>can any one help this.</p><p>tq.
aqef</p>aqef alifhttps://jp.mathworks.com/matlabcentral/profile/authors/9870455-aqef-aliftag:jp.mathworks.com,2005:Question/3319832017-03-26T14:10:49Z2017-03-26T16:49:31ZHow to get diagonal elements of non-square matrix?<p>Hi, guys!</p><p>I am working with rectangular matrixes and I want to extract the values that go from the upper left corner to lower right (diagonal). I have tried to write some codes, but they don't give me good results (it actually gets worst as the matrix gets "more rectangular"). Does anyone have an ideia?</p><p>Thank you,</p><p>Carolina Magalhães</p>Carolina Magalhãeshttps://jp.mathworks.com/matlabcentral/profile/authors/6642945-carolina-magalhaestag:jp.mathworks.com,2005:Question/3320082017-03-26T16:48:10Z2017-03-26T16:48:10Z3DOF Delta Robot simulation?<p>i'm working for integrating work-space of DELTA Robot can somebody help me.?</p>GOVIND HALLALEhttps://jp.mathworks.com/matlabcentral/profile/authors/8089248-govind-hallaletag:jp.mathworks.com,2005:Question/3320072017-03-26T16:47:32Z2017-03-26T16:47:32ZHow to transform this 2D animation into 3D?<p>I made this 2D animation of a projectile motion using the method of ode45:</p><pre class="language-matlab">clc
clear all
v0=input('Set the value of the initial speed: ');
A=input('Set the value of the angle: ');
rad=A*pi/180;
Vy=v0*sin(rad);
</pre><pre class="language-matlab">syms l
g = 9.80665;
Y=(Vy*l)-(g/2*(l^2));
T=solve(Y,l);
</pre><pre class="language-matlab">options=odeset('Maxstep',1e-9,'RelTol',1e-6);
edo=@(t,w)equationOfState(t,w,v0,A);
[t,w] = ode45(edo,[0:1e-2:double(T(2))], [0 Vy 0],'options');
</pre><pre class="language-matlab">xlabel('X'), ylabel('Y'), title('Projectile motion')
comet(w(:,3),w(:,1))
</pre><p>And this fuction:</p><pre class="language-matlab">function f= equationOfState(t,w,v0,A)
G=9.80665;
f= [w(2);
-G;
v0*cos(A)];
end
</pre><p>I need to transform the animation of this projectile motion into a 3D animation. What's the best way to do it? Thanks for your help.</p>Grishttps://jp.mathworks.com/matlabcentral/profile/authors/8563674-gristag:jp.mathworks.com,2005:Question/3318922017-03-25T16:48:33Z2017-03-26T16:44:35ZMATLAB timer code to make the data flow in real time rather than get congested<p>Hello,</p><p>I am new to Matlab and am seeking help regarding stopping a timer function. I apologise in advance if I use the wrong terminology.</p><p>I have both a start and stop button. I have been able to create the timer and both buttons. When I press the start button the timer function begins and starts EEG data following in. I want the timer function to be stopped in another call back, which is the stop button. When I press stop I want the timer to stop.</p><p>I am struggling to code this. Please find attached the code.</p><p>Thanks in advance for any help provided.</p><p>Cheers</p>sufyan patelhttps://jp.mathworks.com/matlabcentral/profile/authors/9170995-sufyan-pateltag:jp.mathworks.com,2005:Question/3315532017-03-23T16:27:10Z2017-03-26T16:43:30Zi cant sign into my matlab account!!! i have the right username and password but i says "an error has occured"<p>i really really need to install a support package but i cant do it as matlab 2016 wont let me sign in!! PLEASE HELP!</p>afnan faroukhttps://jp.mathworks.com/matlabcentral/profile/authors/7054616-afnan-farouktag:jp.mathworks.com,2005:Question/3319732017-03-26T12:43:30Z2017-03-26T16:38:23ZMacOS: R2017a keeps asking "Allow incoming connections"<p>Running MacOS 10.12.3
On each invocation of Matlab R2017a, MacOS asks "Allow incoming connections, Allow / Deny". The answer doesn't get remembered for the next time I open Matlab. I have Matlab 2016a and 2017a installed side-by-side. The issue doesn't occur on MATLAB_R2016a, only on MATLAB_R2017a. I have worked around this by adding manually the file "/Applications/MATLAB_R2017a.app/Contents/MacOS/MATLAB" to the Firewall allowed list. I had to do this manually, as it wouldn't remember the setting from the prompt.</p>Noah Kanovskyhttps://jp.mathworks.com/matlabcentral/profile/authors/5501448-noah-kanovskytag:jp.mathworks.com,2005:Question/3320062017-03-26T16:37:04Z2017-03-26T16:37:04ZWhat do I do if i get an error like this when I am designing the fuzzy controller<p>Error using mean
Too many input arguments.</p><p>Error in ruleview (line 439)
inputVector=mean(inRange,2);</p><p>Error in ruleview (line 313)
ruleview #update</p><p>Error in fisgui (line 102)
eval([tag '(fis);']);</p><p>Error while evaluating uimenu Callback</p>Silpa Baburajanhttps://jp.mathworks.com/matlabcentral/profile/authors/9001066-silpa-baburajantag:jp.mathworks.com,2005:Question/3320052017-03-26T16:36:23Z2017-03-26T16:36:23ZHOG feature extraction for 112x92<p>person = 5;
[hogFeature, visualization]= ...
extractHOGFeatures(read(training(person),1));
figure
This is the code for face detection. The code extracts the first image of a person. the image size is 112x92. In the workspace the hog feature shows 1x4680, for different dimension of image the hog feature value changes. I am unable to understand the changes of HOG feature. Can anyone help me please</p>Tousif Ahmedhttps://jp.mathworks.com/matlabcentral/profile/authors/9853263-tousif-ahmedtag:jp.mathworks.com,2005:Question/3320042017-03-26T16:34:53Z2017-03-26T16:34:53ZSVM: Classify using LearnerWeights<p>I used fitcecoc to train a multiclass svm algorithm on MATLAB, the resulting struct has all the weights and the bias. Which formula should I use to classify a new data x without using predict? I've tried this one: f=x'*weight+bias but it doesn't work. Please help! Thank you!!</p>Elisabetta Besanahttps://jp.mathworks.com/matlabcentral/profile/authors/7243560-elisabetta-besanatag:jp.mathworks.com,2005:Question/3320032017-03-26T16:30:04Z2017-03-26T16:30:04Zintersection of a line and 2-d plot based on vector data <p>Hi, I have a 2-d line plot generated with two vectors. I would like to find out intersection point when I draw a horizontal line from y-axis. How should I proceed?</p><img src = "/matlabcentral/answers/uploaded_files/73431/Capture.PNG"><p>Thank you</p><p>Regards,</p>Mike Leehttps://jp.mathworks.com/matlabcentral/profile/authors/5106932-mike-leetag:jp.mathworks.com,2005:Question/3320022017-03-26T16:27:42Z2017-03-26T16:27:42ZHow to convert 400 images to Gray scale<p>I have 400 images stored in a folder which are color photos, i need to convert them to gray scale and I need to resize them to 112x92 and should store the converted and resized images in a file. Please help me with the code.</p>Tousif Ahmedhttps://jp.mathworks.com/matlabcentral/profile/authors/9853263-tousif-ahmedtag:jp.mathworks.com,2005:Question/3320012017-03-26T16:15:55Z2017-03-26T16:15:55ZIs it possible to detect a tumor region from MRI by using classifier? How to detect it ?<p>Its easy to classify the detected tumor into types by using classifier. But How can detect the tumor from MRI by using classifier.</p>sam CPhttps://jp.mathworks.com/matlabcentral/profile/authors/8044262-sam-cptag:jp.mathworks.com,2005:Question/3319452017-03-26T05:35:56Z2017-03-26T16:11:04ZUTF-8 strings in MEX-files<p>This question has been asked here before, but not with any satisfying answers. Since all those answers, a new documented function <a href = "https://www.mathworks.com/help/matlab/apiref/mxarraytoutf8string.html">mxArrayToUTF8String</a> has appeared. I'm hoping to find the function that does the reverse: make an mxArray from a UTF-8 encoded C or C++ string. I'm OK with an undocumented function, or using a bit of code from someone else. I'm not OK with linking some huge Unicode library, which I have no use for. All I need is convert UTF-8 to UTF-16 (which seems to be what MATLAB uses in their mxChar arrays).</p><p>Does anybody have any experience with UTF-8 encoded strings in MATLAB?</p><p>What does The MathWorks suggest we do if we want to work with UTF-8 encoded strings?</p>Cris Luengohttps://jp.mathworks.com/matlabcentral/profile/authors/210779-cris-luengotag:jp.mathworks.com,2005:Question/3319882017-03-26T14:37:01Z2017-03-26T16:07:25ZHello, could anyone help me? I have problem to synchronize zoom in a GUI:<p>How to do this with different axes in a GUI, not with subplot.</p><pre class="language-matlab">figure
ax1 = subplot(2,1,1);
RGB = imread('peppers.png');
I = rgb2gray(RGB);
imshow(I);
ax2 = subplot(2,1,2);
RGB = imread('peppers.png');
imshow(RGB);
linkaxes([ax1,ax2],'xy')
</pre>Denilsonhttps://jp.mathworks.com/matlabcentral/profile/authors/5901095-denilsontag:jp.mathworks.com,2005:Question/3320002017-03-26T16:05:37Z2017-03-26T16:09:40ZHow Can i write values in excel row by row??<p>can anyone tell me how am i supposed to write values to excel but in row by row manner i have 8 images and i have calculated the energy,entropy,dissimilarity,auto-corelation,contrast now i have stored them in a,b,c,d,e respectively
and then in x=[a b c d e] so i want to write these values row by row in cell.And they are different since i am processing 8 images from a folder.The code i have written writes only the last value 8 times row by row in the excel sheet. please i need urgent help..thanks in advance.</p><p>Code:</p><p>srcFiles = dir('C:\Users\sagar\Desktop\Abnormal\*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\sagar\Desktop\Abnormal\',srcFiles(i).name);
I = imread(filename);
% figure, imshow(I);</p><p>t = rgb2gray(I);
w = adapthisteq(t);
GLCM2 = graycomatrix(w);
v = GLCM_Features1(GLCM2,0);</p><p>a = v.autoc
b = v.contr
c = v.dissi
d = v.energ
e = v.entro</p><p>x = [a b c d e]</p><p>offset = 1;
for a_iter = 1:8</p><p>xlswrite('newdata6.xls',x,1,sprintf('A%d',offset));
offset = offset + 1;
end</p><p>end</p>Sagar Sawanthttps://jp.mathworks.com/matlabcentral/profile/authors/9392638-sagar-sawanttag:jp.mathworks.com,2005:Question/3319992017-03-26T16:02:36Z2017-03-26T16:02:36ZHow to remove shadow from image ?<p>I am building a braille dots recognition program. After i acquire image through the camera and convert it into binary, the shadow also becomes significant and hence the result gets affected. Can you suggest me a code to avoid the effect of shadows??
Here is the example image(shadow is on the bottom half part of the image):</p><img src = "/matlabcentral/answers/uploaded_files/73425/66.jpg"><p>Here is the Binary image:</p><img src = "/matlabcentral/answers/uploaded_files/73427/untitled111.jpg"><p>Histogram of the Orignal Image:</p><img src = "/matlabcentral/answers/uploaded_files/73430/zaq.bmp">Zaheer Abbashttps://jp.mathworks.com/matlabcentral/profile/authors/9354031-zaheer-abbastag:jp.mathworks.com,2005:Question/3319842017-03-26T14:11:14Z2017-03-26T16:00:07ZRemove the unwanted region from an image....<p>I have image with an unwanted area, and I want to remove that area and make a mask(RGB) after that operation. How can I easily do this task ?
Note : I have attached an image file in which I need to remove the degraded area from that and create a mask.
Thankz</p><img src = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/73412/kandian.png">Piyum Ranganahttps://jp.mathworks.com/matlabcentral/profile/authors/9634533-piyum-ranganatag:jp.mathworks.com,2005:Question/3319982017-03-26T16:00:05Z2017-03-26T16:00:05ZHow to remove the shadow area or the dark part in the meter display?<p>I'm in the process of converting a picture of electric meter into binary image. Somehow, due to the snapping angle, there is visible of dark part or based shadow appear and it somehow effect the result of the output. I tried the simple adjustment and histogram equalization, but it did not do well. The background removal somehow did not do well too.</p><pre class="language-matlab">f=imread('C:\Users\Yasmin\Documents\MATLAB\Data1.jpg');
a=imresize(f,[300 NaN]);
% Convert the image to gray level image
b= rgb2gray(a);
% Apply adaptive histogram eqaulization to enahnce the contrast of the
% image
c=adapthisteq(b);
figure, imshow(c)
imhist(c);
% Illumination Correction
MN=size(c);
background = imopen(c,strel('rectangle',[0,60]));
figure,imshow(background)
I2 = imsubtract(c,background);
I3= imadjust(I2);
figure,imshow(I3)
% Convert to binary image
level = graythresh(b);
d=im2bw(I3,level);
bw = bwareaopen(d, 50);
imshow (bw)
</pre><p>this is the best result I could obtain compared to my other previous result, the digit in dark area were totally cover up.</p><img src = "/matlabcentral/answers/uploaded_files/73426/untitled.jpg"><p>I'm quite a beginner towards image processing. hope someone could help. It is okay to not follow the the provided code as I don't know if I'm doing it correction or not.</p><img src = "/matlabcentral/answers/uploaded_files/73429/Data1.jpg"><p>the original image</p>Yasminhttps://jp.mathworks.com/matlabcentral/profile/authors/9105987-yasmintag:jp.mathworks.com,2005:Question/3313332017-03-22T16:47:19Z2017-03-26T15:56:55ZReal-time heart rate calculation<p>I have a real-time(phonocardiograph) plot which displays data from an electronic stethoscope via the COM port. I am trying to calculate the heart rate but having little success. I have created a <i>uicontrol</i> on the figure to display the BPM and have included the formulas to count the peak signals(beat_count). At the momement 'BPM:' displays on the plot figure but without a value so I am unable to get any BPM_avg reading.</p><pre> a = arduino('COM4','Due');
y=0;
hPlot = plot(NaN);
intervalSize = 200;
currentInterval = 200;
t = 1; % number of samples
atInterval = 1;
beat_count = 0;</pre><pre> quitbutton = uicontrol('style','pushbutton',...
'string','Quit', ...
'fontsize',12, ...
'position',[10,2,50,20], ...
'callback','quitit=1;close');
quitit = 0;
bpmtext = uicontrol('style', 'text',...
'string', ['BPM: '],...
'fontsize', 12,...
'position', [80, 2, 100, 20]);</pre><pre> while(1)
k = 1;
while(t<currentInterval)
b=readVoltage(a, 'A0');
y=[y,b];
if ishandle(hPlot)
set(hPlot, 'YData', y);
else
break; % break out of the loop
end
xlabel('Samples')
ylabel('Voltage')
title('Phonocardiogram')
axis([currentInterval - intervalSize,currentInterval,0,3]);
%grid
t=t+k;
pause(0.002)
end
for m = 2 : length(b)-1
if(b(m) > b(m-1) & b(m) > b(m+1) & b(m) > 2.4)
%disp('Prominant peak found');
beat_count = beat_count + 1;
set(bpmtext, 'string', ['BPM: ',...
num2str(BPM_avg,4)]);
end
end
currentInterval = currentInterval + intervalSize;
atInterval = atInterval + 1;
if ~ishandle(hPlot)
break;
end
fs = 500;
N = length(b);
duration_in_seconds = N/fs;
duration_in_minutes = duration_in_seconds/60;
BPM_avg = beat_count/duration_in_minutes;</pre><pre> end </pre>bilal malikhttps://jp.mathworks.com/matlabcentral/profile/authors/4821130-bilal-maliktag:jp.mathworks.com,2005:Question/3319972017-03-26T15:54:31Z2017-03-26T15:54:31ZCreate a main script (matlab) that asks the user which expression to show and then draws the appropriate face by calling functions for most of the data. The switch structure can be used as part of this (it can be found in your textbook). Hint: You w<p>Can anyone just solve this problem ? Help will be highly appreciated.</p>Bijaya Nepalhttps://jp.mathworks.com/matlabcentral/profile/authors/9573571-bijaya-nepaltag:jp.mathworks.com,2005:Question/3319462017-03-26T05:50:06Z2017-03-26T15:46:00ZSir I'm working a current project image process or image data acquistion my problem is i have to identify a color red and green when it pass to a live web cam or take a snapshot and i'm confused about the rgb color in matlab ex. if(rgb == red)<p>Sir I'm working a current project image process or image data acquistion my problem is i have to identify a color red and green when it pass to a live web cam or take a snapshot and i'm confused about the rgb color in matlab
ex. if(image == red)
disp ('red');
if(image == green)
disp ('green');
else
......</p>Julius MANILAhttps://jp.mathworks.com/matlabcentral/profile/authors/9903601-julius-manilatag:jp.mathworks.com,2005:Question/1248842014-04-07T19:28:46Z2017-03-26T15:32:56ZAlt+tab not working<p>I want to switch between two windows(tabs minimized to task bar) using matlab..For which I wrote the code</p><pre class="language-matlab">if true
% code
end
import java.awt.Robot;
import java.awt.event.*;
mouse = Robot;
mouse.keyPress (java.awt.event.KeyEvent.VK_ALT);
mouse.keyPress (java.awt.event.KeyEvent.VK_TAB);
mouse.keyRelease (java.awt.event.KeyEvent.VK_TAB);
pause(2);
mouse.keyRelease (java.awt.event.KeyEvent.VK_ALT);
</pre><p>But it doesn't work..It stays as it is..Can anyone help ??
Thanx in advance</p>Animeshhttps://jp.mathworks.com/matlabcentral/profile/authors/4578128-animeshtag:jp.mathworks.com,2005:Question/1227902014-03-24T04:45:49Z2017-03-26T15:32:11Z Iris Recognition Project.<p>I am currently working on an Iris Recognition project for my m.tech thesis.
I have completed the segmentation step. I have two arrays which store the x and y coordinates of the iris and the pupil boundary.
Now, how should I go about extracting the iris region and then encoding it in my matlab code.
Please guide me. I am aware of the theoritical procedure, i need help in the coding part.</p>surabhihttps://jp.mathworks.com/matlabcentral/profile/authors/4580369-surabhitag:jp.mathworks.com,2005:Question/3319752017-03-26T12:52:01Z2017-03-26T15:30:54ZHow to read image data sets from a folder at once ?<p>Hello. I have 40 datasets in a folder in C drive. I need to convert those files from RGB to grayscale and should resize it but i am unable to read the file and cant convert all the files from RGB to gray at once and cant resize all the images at once and should save the converted and resized images. Can anyone help me with the coding of that please</p>Tousif Ahmedhttps://jp.mathworks.com/matlabcentral/profile/authors/9853263-tousif-ahmedtag:jp.mathworks.com,2005:Question/3319932017-03-26T15:04:39Z2017-03-26T15:29:07ZNeed help for a school project(GUI)<p>Hi everyone:) Me and my friends are trying to learn mathlab by ourself. We need to build a gui where you can set a certain value by holding and moving up or down the cursor (you have a cartesian system with values only on the y, you move up and down a straight line parallel to x and you set a value on the y). We also want to save this value as a variable in mathlab. Do you have any suggestions on how to do it or where we should look? thank you very much:)
p.s. english isn't my first language, ask me if you don't understand.</p>Johann Ruaudhttps://jp.mathworks.com/matlabcentral/profile/authors/9900938-johann-ruaudtag:jp.mathworks.com,2005:Question/3319772017-03-26T13:02:38Z2017-03-26T15:28:51ZPloting point according to a matrix <p>Hi
data:
x=[1; 1; 3; 3; 2];
y=[1; 3; 3; 1; 2];
A=[0 1 0 1 0;1 0 1 0 1;0 1 0 1 1;1 0 1 0 0; 0 1 1 0 0];</p><p>I got some trouble plotting this. I got my XY point and need to plot it according to the matrix A. Cant seem to find any help on google and it's should be simpel but im not that good at mathlab</p>Jens Christian Lassenhttps://jp.mathworks.com/matlabcentral/profile/authors/6469706-jens-christian-lassentag:jp.mathworks.com,2005:Question/3206512017-01-16T20:58:28Z2017-03-26T15:27:56Zhelp in background subtraction. <p>I have a background modeled image. and i try to perform background subtraction for the incoming frames in the video, then apply a threshold to extract a foreground object. When i apply a threshold most of the white intensity pixels has lower values falls in the background pixels, which is supposed to be a foreground. this works good for other coloured intensity pixels. As decreasing the threshold value, more of the background falls in the foreground region.</p><p>I am new to background subtraction technique. Is there any advanced technique, any solution to overcome my problem will help me more forward. Expecting some positive reply from experts.</p>jeffinhttps://jp.mathworks.com/matlabcentral/profile/authors/2493703-jeffintag:jp.mathworks.com,2005:Question/3315382017-03-23T15:15:20Z2017-03-26T15:26:53ZDisplay each object in a binary image separately<p>Hello everybody,</p><p>I have an image, with undefined number of objects, just like the image below.</p><img src = "/matlabcentral/answers/uploaded_files/73194/Untitled.png"><p>I want to create an image for each one of the objects. For this case, I want to create 4 images each one with only one object. The new images should have the same size as the original image.</p><p>Is there anyone who could help me?</p><p>Cheers,</p><p>Joaquim</p>Joaquimhttps://jp.mathworks.com/matlabcentral/profile/authors/5352352-joaquimtag:jp.mathworks.com,2005:Question/3319862017-03-26T14:24:08Z2017-03-26T15:21:19ZAligning or justifying multiple text on same title line<p>Hi all,</p><p>I'm looking for a little help on a seemingly simple problem. I have a multiline title similar to this on a plot:</p><pre class="language-matlab">t = title({['\fontsize{14}','First Line Title']; ...
['\fontsize{12}','Second Line Title 1', ...
'Second Line Title 2','Second Line Title 3']}, ...
'FontWeight','Normal')
</pre><p>On the second line I have three pieces of text (Second Line Title 1-3). I'm exporting multiple plots, but the text changes for each plot I make. I'm wanting the alignment (justification) of each piece of text on the second line to remain constant regardless of number of characters so that there isn't a big swing in the justification of each piece of text. Hopefully this makes sense.</p><p>Does anyone have any suggestions on how to do this in MATLAB? Any thoughts or advice would be greatly appreciated!</p>John Crucehttps://jp.mathworks.com/matlabcentral/profile/authors/10022766-john-crucetag:jp.mathworks.com,2005:Question/3319962017-03-26T15:14:28Z2017-03-26T15:14:28ZHow to create a graph without knowing the data points?<p>Hi</p><p>I am trying to create the following graph (exponential when service level goes to 100%) in Matlab (see attached) but can't seem to make it work as I have no data points (function) given.</p><p>Note: 'safety stock requirements' is the label of the y-axis.</p><p>How can I do this?</p><p>Thanks a lot in advance! I really appreciate it!</p>Pieter Cecathttps://jp.mathworks.com/matlabcentral/profile/authors/9982698-pieter-cecattag:jp.mathworks.com,2005:Question/3309392017-03-20T22:53:42Z2017-03-26T15:11:42ZHow to plot 3 line graphs on same graph<p>I am inexperienced in using Matlab and am trying to plot a graph.
The function and what it should look like can be found in the pictures attached.</p><p>Difference with the graph attached is that the curve should be mirrored. In other words, for q = 0, c(q) should be Alpha1 and for q = 1, c(q) should be Alpha0.</p><p>My attempts so far have not been very successful.
Any help would thus be appreciated! Thank you in advance!</p><p>I'm using Matlab 9-1</p>Pieter Cecathttps://jp.mathworks.com/matlabcentral/profile/authors/9982698-pieter-cecattag:jp.mathworks.com,2005:Question/3319952017-03-26T15:08:22Z2017-03-26T15:08:22Zi need to extend the polyfit line until intersect x-axis <p>this is my code ineed to make fitting line intersect x-axis how?
p=[2080 1885 1620 1205 888 645];
z=[0.759 0.767 0.787 0.828 0.866 0.900];
cum=[0 6.873 14.002 23.687 31.009 36.207];
r=p./z;
figure('color','b')
plot(cum,r,'k-.')
set(gca,'Color','y')
xlabel('cummulative production(MMM SCF)')
ylabel('P/Z(psig)')
title('Relation between compersibilty ratio and cumm production')
hold on
f=polyfit(cum,r,1);
k=polyval(f,cum);
plot(cum,k,'b')</p>ahmed ragaiehttps://jp.mathworks.com/matlabcentral/profile/authors/10022689-ahmed-ragaietag:jp.mathworks.com,2005:Question/3319942017-03-26T15:07:34Z2017-03-26T15:07:34ZOutput of isdst incorrect on for 26 March 2017<p>Hello,
The function isdst seems to say that 26 March 2017 London time does not occur during daylight saving time. The output is incorrect, 26 March 2017 (London time) occurs during Daylight Saving Time. The output for 27 March 2017 is correct.
Below is an example which illustrates the problem.</p><p>>> t = datetime(2017, 3, 26, 'TimeZone', 'Europe/London')</p><p>dt =</p><pre class="language-matlab">datetime
</pre><pre> 26-Mar-2017</pre><p>>> isdst(dt)</p><p>ans =</p><pre class="language-matlab">logical
</pre><pre> 0</pre>Florian Theilhttps://jp.mathworks.com/matlabcentral/profile/authors/1264106-florian-theiltag:jp.mathworks.com,2005:Question/3319922017-03-26T14:57:44Z2017-03-26T14:57:44ZHow can I install and run latest MATLAB setup on Ubuntu 16.04 with 3 GB RAM 1.9 GHz Clk speed<p>Request you to clear the cause of installing and running Latest MATLAB set up on 32 bit Ubuntu 16.04 OS with 32 GB RAM and 1.9 GHz Clk speed. Thanx and Regards</p>Rohit Kanshttps://jp.mathworks.com/matlabcentral/profile/authors/10022941-rohit-kanstag:jp.mathworks.com,2005:Question/3319182017-03-25T21:02:18Z2017-03-26T14:56:43ZConvert .txt/.mat to .wav format<p>I have a .txt and a .mat file, both containing the same data. I would like to convert either one(whichever is easier) to a .wav file so that I can play the sound and carry out audio processing. I understand 'wavwrite' is one way of doing this but so far I have been unsuccessful.
I have tried:</p><pre class="language-matlab">>> load('data.mat')
>> hfile='data.wav';
>> wavwrite(y, Fs, hfile)
</pre><p>But when I run the code, it displays:</p><pre class="language-matlab">Undefined function or variable 'y'.
</pre><p>Does anyone know the solution to this problem or even an alternative method to convert a .txt/.mat file to .wav? Thanks</p>bilal malikhttps://jp.mathworks.com/matlabcentral/profile/authors/4821130-bilal-maliktag:jp.mathworks.com,2005:Question/3319592017-03-26T10:19:17Z2017-03-26T14:54:14Zwhy i can't show image in axes in serial callback<p>i need your help! i'm a newbie</p><p>i can't show image in axes by: axes(handles.axes1); imshow('image.jpg');</p><p>my Guide have 2 axes and 2 pushbutton.</p><p>my code:</p><pre> function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global s
s = serial('COM1','Baudrate',9600,'DataBits',8,'Parity','none','StopBits',1);
s.BytesAvailableFcnCount = 1;
s.Timeout = 1;
s.BytesAvailableFcnMode = 'byte';
s.BytesAvailableFcn = @Serial_Callback;
try
fopen(s);
catch err;
if (strcmp(err.identifier,'MATLAB:serial:fopen:opfailed'))
msgbox('Open COMport fail!!! Please try again!','Error','error');
end
end</pre><pre> % --- Executes on button press in pushbutton2.</pre><pre> function Serial_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global video hinh s I J K a S P;
video = videoinput('winvideo',2);
hinh = getsnapshot(video);
imwrite(hinh,'anh.jpg');
a = imread('anh.jpg');
axes(handles.axes1);
imshow(a);
J = rgb2gray(a);
J = imadjust(J);
K = im2bw(J,0.7);
K = imfill(K,'hole');
K = bwareaopen(K,2500);
axes(handles.axes2);
imshow(K);</pre><pre> function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global s;
fclose(s);
close;</pre><p>Error:
Error using feval
Undefined function 'figure1_CreateFcn' for input arguments of type 'double'.</p><p>Error in gui_mainfcn (line 96)
feval(varargin{:});</p><p>Error in doan (line 42)
gui_mainfcn(gui_State, varargin{:});</p><p>Error in @(hObject,eventdata)doan('figure1_CreateFcn',hObject,eventdata,guidata(hObject))</p><p>Error using struct2handle
Error while evaluating figure CreateFcn</p><p>Error using doan>pushbutton2_Callback (line 107)
Not enough input arguments.</p><p>Error in instrcb (line 36)
feval(val{1}, obj, eventStruct, val{2:end});</p><p>Warning: The BytesAvailableFcn is being disabled. To enable the callback property
either connect to the hardware with FOPEN or set the BytesAvailableFcn property.</p><p>Error using edit (line 66)
Undefined function or variable 'hObject'.</p><p>Error in helpUtils.errorDocCallback (line 23)
if ~edit(editTopic)</p>amh limhhttps://jp.mathworks.com/matlabcentral/profile/authors/10012873-amh-limhtag:jp.mathworks.com,2005:Question/3319912017-03-26T14:50:04Z2017-03-26T14:50:04ZModificar celdas especificas de archivo .txt<p>Tengo un archivo de texto .txt
al cual debo modificar solo los valores de ciertas celdas</p><p>en la imagen se puede ver las celdas especificas que debo modificar (Visto desde Excel).</p><p>el problema es que no logro leer el archivo en Matlab y que se conserve como una tabla.</p><img src = "/matlabcentral/answers/uploaded_files/73414/matlab_txt.PNG">byron romerohttps://jp.mathworks.com/matlabcentral/profile/authors/6563579-byron-romerotag:jp.mathworks.com,2005:Question/3315252017-03-23T14:10:38Z2017-03-26T14:49:16ZI got error : Names of fields in structure arrays being concatenated do not match. Concatenation of structure arrays requires that these arrays have the same set of fields.<p>I have used the following files and the error is :</p><p>Error using vertcat
Names of fields in structure arrays being concatenated do not match. Concatenation of structure arrays requires that these arrays have
the same set of fields.</p><p>Error in linearsyntax (line 16)
test=[test0;test1];</p>sam CPhttps://jp.mathworks.com/matlabcentral/profile/authors/8044262-sam-cptag:jp.mathworks.com,2005:Question/3319892017-03-26T14:45:46Z2017-03-26T14:45:46Zfitting function as a sum of different contributions<p>Hello,
I'm fitting my experimental data with a function that can include several terms, each dependant on several parameters, lets say
F([a1,a2,...,an],x)= F1([a1,a2,a3],x) + F2([a4,a5],x) + ... Fi([an-1,an],x)
Sometimes I can neglect one of the terms, sometimes I can neglect another one, sometimes several of them. I'm making a gui to make the fitting procedure as convenient as possible and I'd like to have e.g. tick boxes referring to each of the terms that can be checked or unchecked, depending on what one wants to be included in F. Of course, I can manually write many combinations of fitting functions and corresponding inputs and outputs, but I'm sure there is an easier way to make an instruction
"if tick 1 is checked
include term1 in F"
I'd appreciate any suggestions</p>Malgorzata Florekhttps://jp.mathworks.com/matlabcentral/profile/authors/4884941-malgorzata-florektag:jp.mathworks.com,2005:Question/3319872017-03-26T14:36:28Z2017-03-26T14:36:48ZObtaining source .c for Pixhawk PSP library block<p>Just a follow up on this question:
https://www.mathworks.com/matlabcentral/answers/331663-how-to-compile-tlc-to-mexw64-or-obtain-source-c-file</p><p>Apparently, the only way I can make an adjustment to the disarmed output of the PWM_output block (from the Pixhawk PSP for R2016a) is by editing the source .c file for that block and compiling it myself.</p><p><b>Where can I get a copy of this file (sfun_px4_pwm.c)?</b> I need to make this change to avoid frying my servos.</p>Matthieu Capuanohttps://jp.mathworks.com/matlabcentral/profile/authors/6029688-matthieu-capuanotag:jp.mathworks.com,2005:Question/3319852017-03-26T14:16:35Z2017-03-26T14:29:14Zproblems in operation of Matlab 7 in Windows 10<p>I installed Matlab 7 (R14) on Windows 10. It works o.k except 2 problems.
1) if I run a script or function on step mode (F 10) from a breakpoint, the program gets stuck.
2) in graph figure , if i try to zoom in with the cursor specific area, I get a zoomed area in wrong
location which has offset to the original location.</p>yaakov bar-onhttps://jp.mathworks.com/matlabcentral/profile/authors/7243910-yaakov-bar-ontag:jp.mathworks.com,2005:Question/3318962017-03-25T17:31:24Z2017-03-26T14:09:33ZThe Pitch of signal <p>Hello sir,
According to my knowledge pitch of any signal is nothing but its frequency, so if i keep the same frequency of any signal then the audio that we hear should be same right? While I was working with matlab, what I did is, I kept the frequency same but changed the sampling rate(for the same sinusoid), the result is I got the different sound for 2 different sampling rates. How can that be possible? can you please explain it to me?</p><p>Thank you</p>Nachiket Patkihttps://jp.mathworks.com/matlabcentral/profile/authors/6912172-nachiket-patkitag:jp.mathworks.com,2005:Question/3317722017-03-24T16:50:28Z2017-03-26T14:03:02Zhow can set the string in bar plot??<p>hi everybody
I'm gonna to do this work? What do I do?</p><img src = "/matlabcentral/answers/uploaded_files/73294/Capture.PNG">ahmad hashemihttps://jp.mathworks.com/matlabcentral/profile/authors/9603836-ahmad-hashemitag:jp.mathworks.com,2005:Question/3319812017-03-26T13:55:15Z2017-03-26T14:01:24ZHow to find the average of matrices in a cell??<p>How to find the average of matrices in a cell. the cell is of size 1x10.</p>Darsana P Mhttps://jp.mathworks.com/matlabcentral/profile/authors/9051001-darsana-p-mtag:jp.mathworks.com,2005:Question/3319632017-03-26T10:47:58Z2017-03-26T13:54:18ZI don't understand where the problem is in this system<pre class="language-matlab">if true
% code
switch es
case 1, beta=0.1; k=2; x0=[0;0]; w0=0; tmax=20;
case 2, beta=0.01; k=2; x0=[0;0]; w0=0; tmax=200;
case 3, beta=10; k=20; x0=[0;0]; w0=0; tmax=10;
case 4, beta=0.1; k=2; x0=[0;0.2]; w0=0; tmax=20;
case 5, beta=0.1; k=2; x0=[0;0]; w0=4; tmax=10;
case 6, beta=0.01; k=2; x0=[0;0]; w0=4; tmax=10;
case 7, beta=10; k=20; x0=[0;0]; w0=4; tmax=10;
case 8, beta=0.1; k=2; x0=[0;0.2]; w0=4; tmax=10;
end
m=0.2;
f0=1;
A=[0,-k/m; 1,-k/beta];
B=[1/m,0;0,0];
C=[1,0];
D=0;
sistema=ss(A,B,C,D);
T=0:0.01:tmax;
U=f0*cos(w0*T);
[y,tsim,x]=lsim(sistema,U,T,x0);
end
</pre><p>The error is:
Error using DynamicSystem/lsim (line 84)
When simulating the response to a specific input signal, the input data U must be a matrix with as many rows as
samples in the time vector T, and as many columns as input channels.</p><p>Thanks to all!</p>marco mezzollahttps://jp.mathworks.com/matlabcentral/profile/authors/9998725-marco-mezzollatag:jp.mathworks.com,2005:Question/3278622017-03-03T07:07:05Z2017-03-26T13:48:47ZGuide to implement Side Match Vector Quantization (SMVQ) in MATLAB<p>I am currently working in the field of Steganography. I need to implement SMVQ as a part of my research. Please suggest me some useful study material/URL so that I can implement it in MATLAB. Thanks</p>Amar Kaswanhttps://jp.mathworks.com/matlabcentral/profile/authors/7779688-amar-kaswantag:jp.mathworks.com,2005:Question/3319802017-03-26T13:38:11Z2017-03-26T13:41:59ZMaximum likelihood estimates CDF<p>Good morning, I have a question about how to calculate and plot the maximum likelihood estimates of the mean and standard deviation of a normal distribution using stimuli and results.</p><p>In other words I have these data:
stimuli=[20 25 41 33 55 45 29 43 34 20] with their corresponding results (in which fail=0 and survive=1 for each stimulus): results=[0 1 1 0 0 0 1 1 0 1].</p><p>How can I plot with Matlab a cumulative normal distribution probability curve that considers the stimuli data together with their corresponding results?
I'd like to have a plot like this:</p><img src = "https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/39653/versions/1/screenshot.png"><p>Thanks a lot for your help.</p>CPhttps://jp.mathworks.com/matlabcentral/profile/authors/8264561-cptag:jp.mathworks.com,2005:Question/3318792017-03-25T14:33:59Z2017-03-26T13:28:57ZKeep track of variable value in gui<p>I am designing a program with GUIDE that simulates a coin toss game. It has 3 components:</p><p>+ A static text box, called <i>text1</i> to keep track of your current balance.</p><p>+ An editable text box, called <i>text2</i> so that you can type in the amount you want to bet.</p><p>+ A push button, called <i>button1</i> to simulate a coin toss.</p><p>This is what I have tried:</p><pre> %first, I used the Property Inspector on text1 to change its string from "Static text" to "1000"
%This way, the player starts the game with $1000
Current_Balance=str2double(get(handles.text1,'string'));
%Then, I acquire the bet amount from text2:
Bet=str2double(get(handles.text2,'string'));
%Next, to simulate a coin toss:
result=binornd(1,0.5);
if result==0;
Current_Balance=Current_Balance - Bet;
else Current_Balance=Current_Balance + Bet;
end
%I tried to update the value of Current_Balance with the next code.
%This is where the error message pops up;
set(handles.text1,'string',Current_Balance);</pre><p>What I am trying to do is to calculate and show the new result Current_Balance each time a button is pressed. Any ideas?</p>Nguyen Quanghttps://jp.mathworks.com/matlabcentral/profile/authors/9984516-nguyen-quang