https://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-12-13T18:49:47Ztag:de.mathworks.com,2005:Question/3720712017-12-09T18:49:54Z2017-12-13T18:49:47ZCode for iteration doesn't work<p>Hi everybody, I need support for Matlab iteration code. In particular, I'd like to calculate "lambda_v_ratio" parameter in this code:</p><pre> m=1.5; %politropic exponent
pc_ad=120000; %intake pressure
z_ad=5000; %%quota di adattamento
eta_c=0.8; %compressor efficiency
eta_mc=0.9; %compressor mechanical efficiency
eta_mt=0.9; %turbine mechanical efficiency
Lc = cpa*T_ad/eta_c*((pc_ad/p_ad)^((k-1)/k)-1); %compressor work</pre><pre> for j=1:length(z)
if z(j)<=z_ad
Tc(j) = T(j)+(Lc/cpa); %intake temperature
pc(j)=pc_ad; %intake pressure
else
Tc(j) = T(j)+(Lc/cpa);
beta(j) = (1+((Lc*eta_c./(cpa.*T(j))))).^(k/(k-1)); %pressure ratio
pc(j)=beta(j)*p(j);
end
rho_c(j) = pc(j)/(R*Tc(j)); %intake density
mu(j) = (pc_ad/p0)*((T0./Tc(j)).^0.5); %correct density
lambda_v(j) = lambda_v0* ((T(j)/T0).^0.5); %altitude volumetric efficiency w/o turbocompressor</pre><pre> lambda_v_ratio(j)=0.8;
lambda_v_tc(j) = lambda_v(j)*lambda_v_ratio(j); %volumetric efficiency due to turbocharging
air_flow_rate(j) = lambda_v_tc(j)*rho_c(j)*iV*n/(2*60);
air_mass(j) = lambda_v_tc(j)*rho_c(j)*V; %per cylinder
fuel_mass(j) = air_mass(j)/alfa;
v1(j)= (V+V0)/air_mass(j);
v2(j)=v1(j)/r;
p2(j)=pc(j)*(r^k);
T2(j) = p2(j)*v2(j)/R;
T3(j) = (T2(j)*alfa*cpa+eta_b*Hi*1000000)/(cpg*(1+alfa));
v3(j) = V0/(air_mass(j)+fuel_mass(j));
p3(j) = R*T3(j)/v3(j);
v4(j) = (V+V0)/(air_mass(j)+fuel_mass(j));
p4(j) = p3(j)*((v3(j)/v4(j))^k2);
T4(j) = v4(j)*p4(j)/R;
ps(j)= p4(j)/4;
ps2(j)=((-lambda_v_ratio(j)+1)*m*pc(j)*(r-1))+pc(j);</pre><p>I'd like to calculate "lambda_v_ratio(j)" so that ps(j) and ps2(j) are almost equal (ps(j) and ps2(j) are both functions of lambda_v_ratio(j) and they have to converge).
I tried with this code:</p><pre class="language-matlab">while (abs(ps(j)-ps2(j)))<100
lambda_v_ratio(j)=lambda_v_ratio(j)+0.001
</pre><p>but it didn't work.
Start value of lambda_v_ratio(j) is 0.8.
Any suggestion?
Thanks for your support.</p>Antonio Tricaricohttps://de.mathworks.com/matlabcentral/profile/authors/11714729-antonio-tricaricotag:de.mathworks.com,2005:Question/3727602017-12-13T15:04:23Z2017-12-13T18:49:46ZRed object detection picking up yellow color.<p>Part of my program isolates the red objects in an image and displays them in a binary image. It works well but has been including yellow objects which is an issue. I've tried adjusting the values in my code with no luck.</p><pre class="language-matlab">img = imread(imname);
gimg = rgb2gray(img);
red = imsubtract(img(:,:,1), gimg);
red = medfilt2(red, [4 4]);
red = im2bw(red, 0.15);
redObjects = bwareaopen(red, 200);
</pre><p>The red objects in my image are all exactly [1 0 0]. Is there a way to do this with hsv that might be more accurate or am I missing something simple here?</p>Adam Hickshttps://de.mathworks.com/matlabcentral/profile/authors/11057195-adam-hickstag:de.mathworks.com,2005:Question/3728042017-12-13T18:45:44Z2017-12-13T18:45:44Zfor loop ode 45 changing parameter values<p>I'm trying to run this code and use only the last value of the tspan for the ode45, however I always get 2 values for the final value of the tspan (when t=100)</p><p>This is the code:</p><pre class="language-matlab">ABP=linspace(40,170,131);
ti=0; tf=100;
%change in ABP at every loop
</pre><pre> for i=1:1:length(ABP)
sol = ode45(@first,ti:1:tf, [0 0 0 0 0.205 62.516 12 13.201 0.2 1],[],ABP(i)); %(function, timespan, initial condition for xq,xc,xm1,xm,Ca,P1,V_sa,P2)
end</pre><pre class="language-matlab">%% ========= FUNCTION ==================
function dvdt = first(t,v,ABP)
%code
...ABP used in a set of differential eq...
if t==100
van= (Vsa+Vla)/(Vsab+Vla)
fileID=fopen('van.txt','a');
fprintf(fileID,' %4.3f\n',van);
fclose(fileID);
</pre><pre> end
end</pre><p>Hence, I should end up having a .txt file with 131 values of <b>van</b>, one for each value of <b>ABP</b>. Instead, I end up with double the amount. I also printed the <b>ABP</b> values in the txt file to check, and indeed there were two different (very similar) values of <b>van</b> for each value of <b>ABP</b>.
Any suggestions on how to fix this?</p>gorilla3https://de.mathworks.com/matlabcentral/profile/authors/8874269-gorilla3tag:de.mathworks.com,2005:Question/3728032017-12-13T18:42:59Z2017-12-13T18:42:59Z How Execute statements if else condition <p>Hello Dears
I have a Problem
i Want to make Plots with Matlab for many Excel Files.
but when i change The Excel File ,I must everytime change The Title , The Labels and Legends Manual
can you help me to Programming this think .
ich have a Idee but Matlab can not Executed it .
can someone help me Please i need that for my Thesis.
Thank you</p><pre> % filename='File1';
omega=xlsread(filename);%Matrix 10078*28
[z,s]=size(omega);
t=1:1:10080;% Time vector</pre><pre> if filename=='File1' %everytime i change a File Name but they have a same size
figure(f1)
V1=omega(:,16);
V2=omega(:,17);
V3=omega(:,18);
plot(t,V1,'displayName','L1-N RMS 1/2(1-cyc)Max(V)')
hold on
plot(t,V2,'displayName','L2-N RMS 1/2(1-cyc)Max(V)')
hold on
plot(t,V3,'displayName','L3-N RMS 1/2(1-cyc)Max(V)')
title('Compare the Current Harmonic ')
ylabel('I Max(A)' )</pre><pre> end</pre><pre class="language-matlab">if filename='File2.xlsx'
V1=omega(:,16);
V2=omega(:,17);
V3=omega(:,18);
plot(t,V1,'displayName','L1-N RMS 1/2(1-cyc)Max(V)')
hold on
plot(t,V2,'displayName','L2-N RMS 1/2(1-cyc)Max(V)')
hold on
plot(t,V3,'displayName','L3-N RMS 1/2(1-cyc)Max(V)')
title('Compare the Voltage Harmonic L1 ')
ylabel('U Max(v)' )
</pre><pre class="language-matlab">end
</pre>houssem chedlihttps://de.mathworks.com/matlabcentral/profile/authors/10373479-houssem-chedlitag:de.mathworks.com,2005:Question/3728022017-12-13T18:36:59Z2017-12-13T18:36:59ZGrouping elements of array according to the result of a calculation ?<p>Hi
Please i would a help with a problem, I am not sure how to approach it:
- I have a list of numbers, I want to group them in a groupe, every time the sum of some numbers ( in order ) is divided by 11. It sounds confusing, so let me illustrate it with an exemple :</p><p>I have : A, B, C, D, E, F, G, H, I
if (A+B)/11 = True then create "array" [A, B] and continue
if (A+B+C)/11 = false then continue (A+B+C+D) ect. until i reach the end, then start form
if (B+C), (B+C+D) .... ect</p><p>i hope that made some sens, please how can i best achieve that ?</p>mounim korchihttps://de.mathworks.com/matlabcentral/profile/authors/9328392-mounim-korchitag:de.mathworks.com,2005:Question/3728012017-12-13T18:31:13Z2017-12-13T18:31:13ZMultiple input delay block (simulink)<p>I need more inputs for delay block, how should i do?</p>Damiano Capoccihttps://de.mathworks.com/matlabcentral/profile/authors/10003105-damiano-capoccitag:de.mathworks.com,2005:Question/3726342017-12-12T21:16:42Z2017-12-13T18:30:27Zhow to predetermine the load bins in a histogram?<p>Dear all, I draw a histogram for an array called (single{K}), using the following code, it seems ok but what I need to do is how to determine the ranges of load bins before drawing it? i already defined the number of bins which is 38, but how can i tell matlab to set the bins with fixed increments, such as: 3000 to 40000 lb at 1000 lb interval?
attached is my histogram which needs help</p><pre class="language-matlab">figure
histogram(single{K}, 38)
xlabel('Load in Kips')
ylabel('Counts')
title(['ALS for C9 Single For Month ',num2str(months),' ', 'Station' ,' ', num2str(stations)])
</pre>MAHMOUD ALZIOUDhttps://de.mathworks.com/matlabcentral/profile/authors/8908523-mahmoud-alzioudtag:de.mathworks.com,2005:Question/3728002017-12-13T18:22:03Z2017-12-13T18:22:03ZHow to find minimum distance between two cylindrical objects from binary image? <p>Hello,</p><p>I have this binary image</p><img src = "/matlabcentral/answers/uploaded_files/98453/aa.jpg"><p>in which I have two cylindrical objects and I want to find out the minimum distance between these. How to do that? I have read <a href = "https://in.mathworks.com/matlabcentral/answers/274956-distance-between-two-objects">this answer</a> but I cannot understand this. Can anyone help to calculate minimum distance in a more simple way?
Thanks.</p>NASEEB SINGHhttps://de.mathworks.com/matlabcentral/profile/authors/7431288-naseeb-singhtag:de.mathworks.com,2005:Question/3727992017-12-13T18:21:58Z2017-12-13T18:21:58ZProjection of an Image <p>If I know the four corners of a rectangle that has been projected, how can I obtain a top-down view of that image using image projection. I tried to use fitgeotrans and imwarp but did not obtain the correct results. Below is the code I used:</p><pre class="language-matlab">U = double([topLeft; topRight; bottomRight; bottomLeft]);
topLeftNew = [1 1];
topRightNew = [1 width];
bottomLeftNew = [height 1];
bottomRightNew = [height width];
X = double([topLeftNew; topRightNew; bottomRightNew; bottomLeftNew]);
tform = fitgeotrans(U, X, 'projective');
B = imwarp(orig, tform);
</pre><p>Does anyone know what I could do to fix this or a different method? The image I'm trying to transform is:</p><img src = "/matlabcentral/answers/uploaded_files/98452/untitled.png"><p>The four corners I've obtained are shown as well. The result of the transformation is.</p><img src = "/matlabcentral/answers/uploaded_files/98454/untitled.png"><p>I'd like for the result to only contain the notecard and orient it correctly upright as well. Is this possible and how can I go about achieving this?</p>Logan Davishttps://de.mathworks.com/matlabcentral/profile/authors/6165682-logan-davistag:de.mathworks.com,2005:Question/1522011-01-18T20:35:44Z2017-12-13T18:20:21ZCan MATLAB pass by reference?<p>How does MATLAB deal with this?</p>Doug Hullhttps://de.mathworks.com/matlabcentral/profile/authors/6503672-doug-hulltag:de.mathworks.com,2005:Question/3727862017-12-13T16:51:18Z2017-12-13T18:15:50ZMaking a three column matrix<p>Hi everyone!
I am having trouble with the following:
I have built a 31 row by 3 columns ceros matrix and I am trying to index values to each column, I want my first column to go from 140 to 440(this are lengths), but when trying to do so my values start from 0, then 140, then 440...
Then in the second column I want the values of column 1 to appear because I need to compare how many lengths are being acumulated( this to later build a histogram..)
I would very much appreciate your help!</p>Liliana Sierrahttps://de.mathworks.com/matlabcentral/profile/authors/11262420-liliana-sierratag:de.mathworks.com,2005:Question/3727842017-12-13T16:48:31Z2017-12-13T18:13:13ZWhat is the most efficient way to find the position in the column of a matrix where the value drops below a given threshold (values are constantly decreasing down the columns)?<p>I have a large (up to 1000x1000) matrix which is the solution to a pde - the columns are the increments in time and the rows are the increments in space. The values down each column are decreasing and I want to find the row of each column where the value drops below a certain value (1 in the code below) and store these values in a vector where the value at each position is the row where it drops below the threshold. My method works perfectly well but is very slow, is there a better way?</p><p>My code:</p><pre class="language-matlab">timeivector = 2:state.Numberoftimesteps; %starts at 2 since initial condition is zero everywhere
spaceivector = 1:state.Numberofspacesteps;
</pre><pre class="language-matlab">for ti = timeivector
for xi = spaceivector
if largematrix(xi,ti) <= 1
continue
end
outputvector(ti) = xi+1;
end
end
</pre>J2A2B2https://de.mathworks.com/matlabcentral/profile/authors/7101258-j2a2b2tag:de.mathworks.com,2005:Question/3727452017-12-13T13:37:41Z2017-12-13T18:09:48ZHow can I set the numbers of decimals (precision) of the solution of fminunc?<p>I am minimizing a multivariable function using fminunc and I am interested in a solution with just two decimals (ex. A=3.04, not A=3.0421). This is because I am minimizing the error through calibrating some coefficients and I want those coefficients to have a certain precision.</p>Patricia Mares Nasarrehttps://de.mathworks.com/matlabcentral/profile/authors/10255309-patricia-mares-nasarretag:de.mathworks.com,2005:Question/3727972017-12-13T17:53:04Z2017-12-13T18:07:48ZHow can I generate these two chromosome ?<p>Hello everyone,
I want to generate two chromosomes, the first one including random selection from a set of jobs for example j=[1 2 4;3 5 6;...] and pm tasks that are limited to be done in a specific time range. And the second chromosome includes the number of machines like Machines=[m1,m2,m3].
any help would be appreciated.</p>Arash Aphttps://de.mathworks.com/matlabcentral/profile/authors/11714892-arash-aptag:de.mathworks.com,2005:Question/3726022017-12-12T17:48:57Z2017-12-13T18:02:31ZNormalizing columns: Does my function do the same as "normc"?<p>I don't have access to the Neural Network Toolbox and "normc", so I decided to write my own function which normalizes the columns of a matrix (to length 1).
Can somebody please tell me, if my function would deliver the same results as "normc" or would there be a difference for a random matrix "A"?</p><pre class="language-matlab">k = 1:size(A,2)
</pre><pre class="language-matlab">output(:,k) = A(:,k) ./ norm(A(:,k));
</pre><pre class="language-matlab">end
</pre><p>When I test my own function on a random matrix I get the following result. Would the real normc deliver the same results?</p><pre class="language-matlab">result = normc_fake([0.3223 0.4342 0.2442; 0.003 0.3323 0.3332; 4.333 2.222 4.444])
</pre><pre class="language-matlab">result =
0.0742 0.1897 0.0547
0.0007 0.1452 0.0747
0.9972 0.9710 0.9957
</pre><p>Thanks so much.</p>fishandcathttps://de.mathworks.com/matlabcentral/profile/authors/4803806-fishandcattag:de.mathworks.com,2005:Question/3727142017-12-13T10:58:22Z2017-12-13T18:01:57Zhi.how to convert cell array to table?. i tried using cell2table() but it shows an error 'invalid function for the type cell'<pre class="language-matlab">if true
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height =[71;69;64;67;64];
Age=cellstr(num2str(Age));
Height=cellstr(num2str(Height));
T = [{'','age','height'};[LastName,Age,Height]];
t=cell2table(T)
</pre><pre class="language-matlab">end
</pre>alankrita asthanahttps://de.mathworks.com/matlabcentral/profile/authors/11396682-alankrita-asthanatag:de.mathworks.com,2005:Question/3727922017-12-13T17:06:05Z2017-12-13T17:56:43ZHi! Would you please help me :] the db.mat only save the last input image value. this don't give multiple images input values.<pre> %%Module Training
clc;
clear all;
close all;
[fname path]=uigetfile('.jpg','Open a Face as input for Training');
fname=strcat(path,fname);
img=imread(fname);
imshow(img);
%%drawnow;
title('Input Face');
c=input('Enter the Class ');
%%Feature Extraction
F = FeatureStatistical(img);</pre><pre> try
S = load('db.mat');
F=[F c];
db=[db;F];
save db.mat db
catch
F=reshape(F,[3,2]);
F=reshape(F,[1,6]);
db=[F c];
save db.mat db
end</pre><pre> %%FeatureStatistical
function [F]= FeatureStatistical(img)
img=double(img);
mn=mean(mean(img));
sd=std(std(img));
F=[mn sd];</pre><pre> %%FaceClassifier</pre><pre> clc;
clear all;
close all;
[fname path]=uigetfile('.jpg','Provide a Face for Testing');
fname=strcat(path,fname);
img=imread(fname);
imshow(img);
title('Test Face');</pre><pre> Ftest = FeatureStatistical(img);
load db.mat
Ftrain=db(:,1:2);
Ctrain=db(:,7);
for(i=1:size(Ftrain,1))
dist(i,:)=sum(abs(Ftrain(i,:)-Ftest));
end
Min=min(dist);
if(Min<3)</pre><pre> m=find(dist==Min,1);
det_class=Ctrain(m);
msgbox(strcat('Detected Class= ',num2str(det_class)));
else
msgbox('Not Same');
end</pre>Md.Mahabub Al Islamhttps://de.mathworks.com/matlabcentral/profile/authors/11306539-md-mahabub-al-islamtag:de.mathworks.com,2005:Question/3727982017-12-13T17:56:32Z2017-12-13T17:56:32ZIf a cell array of handle objects has a cell deleted using an assignment of [], does MATLAB automatically delete the handle object in the deleted cell referencing it?<p>Will it persist if there are no other variables referencing the handle object?</p><p>Is this a potential memory leak? Will it be a potential memory leak when using Code
Generation? Some code is below but the scenario where there are no other variables referencing the handle object from the deleted cell is hard to test.</p><p><b>***</b> Handle Class for Testing Cell Array Memory Leak <b>***</b></p><pre class="language-matlab">classdef DummyHndObj < handle
% Handle Class for Testing Cell Array Memory Leak
</pre><pre> properties
Property1
end</pre><pre> methods
function obj = DummyHndObj(inputArg1)
obj.Property1 = inputArg1;
end
end
end</pre><p><b>***</b> Test Script for Cell Array Memory Leak <b>***</b></p><pre> % Test Script for Cell Array Memory Leak</pre><pre> % If a cell array of handle objects has a cell deleted using an assignment
% of [], does MATLAB automatically delete the handle object in the deleted cell
% referencing it?
%
% Will it persist if there are other variables referencing the handle object?
%
% Is this a potential memory leak? Will it be a potential memory when using Code
% Generation?</pre><pre> clc
clear all
close all</pre><pre> MemTest = cell(5,1);
for i = 1:5
MemTest{i} = DummyHndObj(i);
end</pre><pre> MemTest
% When using the [] assignment to remove a cell from a cell array loaded
% with handle objects, are the handle objects cleared and removed from memory?
h2 = MemTest{2}
MemTest(2) = []</pre><pre> %% The handle object referenced by h2 appears to persist in memory.
h2
% Until the handle object is deleted
delete(h2)
h2</pre><pre> %% This clearly indicates that the handle object in the cell array has been deleted.
MemTest
h3 = MemTest{3}</pre><pre> delete(MemTest{3})</pre><pre> % Neither handle points to valid object
h3
MemTest{3}</pre><pre> % By not deleting the handle object in the cell prior to deleting the cell
% from the cell array creating a memory leak problem?</pre>Jeff Watsonhttps://de.mathworks.com/matlabcentral/profile/authors/1646766-jeff-watsontag:de.mathworks.com,2005:Question/3722692017-12-11T11:00:31Z2017-12-13T17:54:54ZThe function above cannot be permitted in the context!!! If it needs to create a function file to save it, how?<pre class="language-matlab">function ookd(g,f)
%For more information, visit: www.matpic.com
%Modulation OOK
% Example:
% ookd([1 1 0 1 0],2)
%Author: Diego Orlando Barragn Guerrero
%diegokillemall@yahoo.com
%Loja (ECUADOR)
%Long Live Heavy-Metal
%See also:
%http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14328&objectType=FILE
if nargin > 2
error('Too many input arguments');
elseif nargin==1
f=1;
end
</pre><pre class="language-matlab">if f<1;
error('Frequency must be bigger than 1');
end
</pre><pre class="language-matlab">t=0:2*pi/99:2*pi;
cp=[];sp=[];
mod=[];mod1=[];bit=[];
</pre><pre class="language-matlab">for n=1:length(g);
if g(n)==0;
die=zeros(1,100); %Modulante
se=zeros(1,100); %Seal
else g(n)==1;
die=ones(1,100); %Modulante
se=ones(1,100); %Seal
end
c=sin(f*t);
cp=[cp die];
mod=[mod c];
bit=[bit se];
end
</pre><pre class="language-matlab">ook=cp.*mod;
subplot(2,1,1);plot(bit,'LineWidth',1.5);grid on;
title('Binary Signal');
axis([0 100*length(g) -2.5 2.5]);
</pre><pre class="language-matlab">subplot(2,1,2);plot(ook,'LineWidth',1.5);grid on;
title('OOK modulation');
axis([0 100*length(g) -2.5 2.5]);
</pre>Alex Phanghttps://de.mathworks.com/matlabcentral/profile/authors/11724246-alex-phangtag:de.mathworks.com,2005:Question/3727702017-12-13T15:53:48Z2017-12-13T17:53:22ZIf A2 and B7´s content were 1 - then how to fill A3 to A6 with ones by function??<p>Hi. I´ve described my problem in the picture...
My action looked like that:</p><pre class="language-matlab">for m=2:e-a
if X(m,1)==1 || X(1:e-a,3)==1 && X(m,2)==0
X(m,3)=1;
else
X(m,3)=0;
end
end
</pre><p>That should be repeated other way round for Column 4.
Problem: I´ve got a glimpse of an idea that MatLab doesn´t like, if i refer to a cell in the output column?!
Do you have any other option to fill the cells with ones easier? Thanks very much!</p>Jonas Maurerhttps://de.mathworks.com/matlabcentral/profile/authors/10725735-jonas-maurertag:de.mathworks.com,2005:Question/3727752017-12-13T16:15:19Z2017-12-13T17:49:17ZIs it possible to use mat.h outside Matlab?<p>I used mat.h in Matlab generated executable using the mex file. I was wondering, is it possible to use this Matlab API in a separate IDE such as Visual Studio?</p>Sndn_Shrhttps://de.mathworks.com/matlabcentral/profile/authors/5362222-sndn_shrtag:de.mathworks.com,2005:Question/3727962017-12-13T17:46:03Z2017-12-13T17:46:03ZSimulink PIL on embedded Linux system from Matlab running on Windows<p>Hi All,
I am currently running a Simulink Model on Windows and working on exporting one subsystem to C++ code.
I have SIL running successfully
I have compiled the generated code on my target hardware and I have a test program that will do basic input/output verification.</p><p>But we want to run PIL. As I understand that we would run Matlab from Windows and connect via Ethernet to our target processor.
But our target processor is a PowerPc running Linux.</p><p>So is this even possible? I have not found a support package for this hardware.</p><p>We currently have a cross compiler running on CentOs and I have found some documentation that suggests maybe it would work on Windows using CROPS and Docker Containers.. But I am not very confident we can get this working.</p><p>Is there any way to run PIL so that it would compile the subsystem on the target hardware?</p><p>Or is there a way to configure Simulink to connect to an executable that was previously compiled and running on the target system?</p>Tamara OToolehttps://de.mathworks.com/matlabcentral/profile/authors/11523417-tamara-otooletag:de.mathworks.com,2005:Question/3727952017-12-13T17:45:24Z2017-12-13T17:45:24ZHow to use GMM algorithm for brain segmentation ?<p>I have to use GMM algorithm for brain segmentation (brain lesion detection), please someone give me an example of the matlab algorithm.</p>marwa zahttps://de.mathworks.com/matlabcentral/profile/authors/6314589-marwa-zatag:de.mathworks.com,2005:Question/3727792017-12-13T16:36:27Z2017-12-13T17:41:21ZExtract rows separately from multiple files.<p>I have 90 files each with three columns and about 2000 rows of data.
I want to match/extract the first row in each of the files together, then the second, then the third and so on.
Anyone know an efficient way of doing this?
Thanks</p>Carol Smythhttps://de.mathworks.com/matlabcentral/profile/authors/11316246-carol-smythtag:de.mathworks.com,2005:Question/3727872017-12-13T16:52:28Z2017-12-13T17:36:33ZAssigning multiple variables vectors from a cell array<p>I'm wondering if there is any smart solution on how to access multiple same-sized vectors inside of a cell array and assign them to an independent variable.</p><pre class="language-matlab">cellArray =
</pre><pre> 1×4 cell array</pre><pre> {1×101 double} {1×101 double} {1×101 double} {1×101 double}</pre><p>Thanks!</p>Johannes Bergerhttps://de.mathworks.com/matlabcentral/profile/authors/9534938-johannes-bergertag:de.mathworks.com,2005:Question/3727892017-12-13T16:55:08Z2017-12-13T17:34:23Zrelative calculation from a column<p>hi guys.
i have the following array A</p><pre> 1 2
--- ---
2
3
10
1
7
8
2</pre><p>i want create a column 2, which is made from the Excel formula:</p><pre> =RC[-1]/average(RC[-1]:R[-3]C[-1])</pre><p>so the result would be</p><pre> 1 2
--- ---
2
3
10 2
1 0.21
7 1.16
8 1.5
2 0.35</pre><p>i want to do it from matlab. But i don't know where do i start...</p>eric capnuhttps://de.mathworks.com/matlabcentral/profile/authors/10441913-eric-capnutag:de.mathworks.com,2005:Question/3727942017-12-13T17:33:02Z2017-12-13T17:34:08ZHow can implement morphological hole filling equation(its formul). I can locate the initial hole positions by user input.(how can get it)?<pre> % code</pre>angel216https://de.mathworks.com/matlabcentral/profile/authors/11744421-angel216tag:de.mathworks.com,2005:Question/3726732017-12-13T05:28:21Z2017-12-13T17:33:20Zcoverting simulink to m-codes<p>I have built a Simulink model and I need to convert it to Matlab m-codes. how can I accomplish it?</p>hh jhttps://de.mathworks.com/matlabcentral/profile/authors/8710791-hh-jtag:de.mathworks.com,2005:Question/1223472014-03-20T06:34:02Z2017-12-13T17:31:38ZMatlab/Editor windows and fonts resize (get smaller) on right click ... why?<p>Hi There,</p><p>I am using MATLAB 2013b (64bit) on a Windows convertible laptop (Win 8.1 - 64bit).</p><p>When the MATLAB runs at the beginning the size of the windows and fonts are all normal compared to the system's font and display sizes, but once I do a right click everything gets re-sized (smaller) and I would have to restart the program to go back to normal.</p><p>If I had to explain it better, the effects are similar to "Changing the Size of all items" for display in the Windows system from 150% to 100%.</p><p>Does anybody know why this happens and if there is a fix for it?</p><p>Thank you in advanced ...
HoSsEiN</p>Hosseinhttps://de.mathworks.com/matlabcentral/profile/authors/2953709-hosseintag:de.mathworks.com,2005:Question/3727782017-12-13T16:29:37Z2017-12-13T17:30:53ZHow do I plot 3 gaussian fits in one graph ?<p>Hi,</p><p>So I'm new to matlab and I'd need some help ! I have 3 series of values that have the same X. I already know how to simply plot them in the same graph. Now what I'd like to do is apply a Gauss fit on the 3 curves, while keeping them in the same graph, to better observe the differences of the series between them. Can someone help me with some directions or scripts ? Thank you !</p>Rudy Lussiezhttps://de.mathworks.com/matlabcentral/profile/authors/11684396-rudy-lussieztag:de.mathworks.com,2005:Question/3727902017-12-13T16:57:47Z2017-12-13T17:30:28ZIs it possible to disable or get warnings when using .* on mismatched vectors?<p>I've finally moved up from 2014b and I see there is a new feature(s) that lets you do math operations that would have previously resulted in errors. For example, you can now use .* on vectors of different shapes. I can see how this could be handy sometimes, but in practice, I lose track of whether a vector is a row or column and instead of getting an error, MATLAB makes a big matrix and moves on. In bad cases, the math to follow is also valid resulting in weird answers. Is there a way to at least have this give out a warning?</p>Chuck37https://de.mathworks.com/matlabcentral/profile/authors/2235717-chuck37tag:de.mathworks.com,2005:Question/3534272017-08-21T01:28:21Z2017-12-13T17:26:54ZIs it possible to create a 3D skeletonisation of vessels with matlab, if neither the 2D (used in 3 directions) nor the Skeleton3D(method for a user) works ?<p>I would need to do a 3D skeletonisation of vessels. My problem is that the bwmorph only works in 2D. Therefore I had the idea to use the method on 3-D by summing up all the 2D contenst from x,y,z -plane and only taking content which is in all images present.
This is my method:
(threeDStack_binary_inFunction=binarized 3D image;times= number of stacks; methodnumber to choose with method of bwmorph is used,skel is a 3D image of the function "Skeleton3D"; this method only works if the image is a square at the moment, which is the case in my images, but the results are not very good)</p><pre class="language-matlab">function [final] = createSkel3D_Method(threeDStack_binary_inFunction,times,methodnumber,connection_number,skel)
%% morphological analysis in all direction
a={'thin';'shrink';'tophat';'skel';'close';'bothat';'open';'bridge';'fill';'diag';'thicken'};
BW3_test_thin=cell(1,times);
for k = 1: times%num_images
BW3_test_thin{k}= bwmorph(threeDStack_binary_inFunction(:,:,k),a{methodnumber},inf);
end
%sum(sum(BW3_test{k}-BW3{k}))
</pre><pre class="language-matlab">BW2_test_thin=cell(1,size(threeDStack_binary_inFunction,2));
BW1_test_thin=cell(1,size(threeDStack_binary_inFunction,2));
for n=1:size(threeDStack_binary_inFunction,2)
BW2_test_thin{n}= bwmorph(squeeze(threeDStack_binary_inFunction(:,n,:)),a{methodnumber},inf);
BW1_test_thin{n}= bwmorph(squeeze(threeDStack_binary_inFunction(n,:,:)),a{methodnumber},inf);
end
%% create 3D images of each plane
%3
BW3_test_thin_threeDStack_binary_inFunction= cat(3,BW3_test_thin{:});
%2
BW2_test_thin_threeDStack_binary_inFunction= cat(3,BW2_test_thin{:});
AA_2_thin=permute(BW2_test_thin_threeDStack_binary_inFunction, [1 3 2]);
%1
BW1_test_thin_threeDStack_binary_inFunction= cat(3,BW1_test_thin{:});
AA_1_thin=permute(BW1_test_thin_threeDStack_binary_inFunction, [3 1 2]);
%% create final output
% sum together all the images and if the number is higher, equal to connection number it can be considered as vessel (-skeleton)
final= (((AA_1_thin+AA_2_thin+BW3_test_thin_threeDStack_binary_inFunction+skel))>=connection_number);
end
</pre><p>I tried to create this method because using "Skeleton3D" still creates some artefacts, which look like bowls (which are only one layer thick but they are not vessels, or just wrong skeletonized vessels)</p><p>The problem with this 2D skeletonisation is that the vessels in the end are not as connected as I see they should have to be using the connected objects. (So I was thinking of using the watershed method in 3D version to achieve good vessel interconnection by knowing which size a connected object should have by this watershed function)</p><pre class="language-matlab">figure,imshow(label2rgb(watershed(~threeDStack_binary_inFunction(:,:,50))))
</pre><p>I just wanted to ask if someone would have an easier approach? Or a short code for such a method ?</p>Colin Rohnerhttps://de.mathworks.com/matlabcentral/profile/authors/8022962-colin-rohnertag:de.mathworks.com,2005:Question/533292012-11-09T19:35:15Z2017-12-13T17:20:02ZFinding center of rotation from two sets of points<p>Given a set of 2D points and the same set of 2D points rotated about an unknown point, how can I find the center of rotation and the amount of rotation?</p>Hans Dohsehttps://de.mathworks.com/matlabcentral/profile/authors/777198-hans-dohsetag:de.mathworks.com,2005:Question/3727522017-12-13T14:09:50Z2017-12-13T17:15:24ZHow can I control a revolute joint with a stepper motor ?<p>Hello, I want to control a stage which is actuated by a lead screw and stepper motor. Ideally, I need to specify the velocity of the stage or angular velocity of the rotational joint 1 so that it rotates the screw. I used simscape to generate the block diagram from my CAD model from onshape (link below). Is there any way of doing this ? I have tried using the stepper motor model from the simelectronics library but had trouble connecting it to the joint.</p><p>Simscape model:
https://drive.google.com/open?id=1WBuGkkchPfXhgrx0C9gV4moEqcxCi6hq</p><p>CAD model:
https://cad.onshape.com/documents/d5ee5d8b466e6650b9cfdac4/w/b05ebd7e69bda94f37ce5c0e/e/71f3ef6f9e38afb071c64dfd</p><p>Thank you</p>Georges Nomicoshttps://de.mathworks.com/matlabcentral/profile/authors/7517626-georges-nomicostag:de.mathworks.com,2005:Question/3727472017-12-13T13:44:46Z2017-12-13T17:14:18ZSpectrum Analyser: One-third octave bands<p>Hi,</p><p>I need to customise the Spectrum Analyser X axis ticks and labels to new values that correspond to the One-third octave frequency bands.
I put the description values below:</p><p>Wikipedia Link: <a href = "https://en.wikipedia.org/wiki/Octave_band">Table: One-third octave bands</a></p><p>How can I do it?</p>Nycholas Maiahttps://de.mathworks.com/matlabcentral/profile/authors/8458420-nycholas-maiatag:de.mathworks.com,2005:Question/3727932017-12-13T17:12:08Z2017-12-13T17:12:08ZR2016a Why my title don't centralize?<p>Hi,</p><p>I started using the matlab R2016a recently and the title of my figures are not getting centralized. How can I fix this?</p>Leilane Passoshttps://de.mathworks.com/matlabcentral/profile/authors/11163127-leilane-passostag:de.mathworks.com,2005:Question/3726952017-12-13T09:53:45Z2017-12-13T17:10:33ZThe function F2 is not working correctly. I have to solve a second order differential equation and the ODE45 solver in the main function doesnt run. The main function actually takes values from two other functions, so whx is my ODE45 not working ? <p>function mainScarg</p><pre> v_fb = zeros(40,1);
v_rate = zeros(40,1);
v_fin = zeros(40,1);
tdet = zeros(40,1);
ysol = zeros(40,1);
D_or= 13.78e-03;
so = zeros(40,1);
ub = zeros(40,1);
options.StepTolerance = 1e-12;</pre><pre> for i=1:40</pre><pre class="language-matlab">v_rate(i) = 1e-6+(i-1)*5e-6; % Volumetric Flow Rate
v_fb(i) = fsolve(@(x)scarg(x,v_rate(i)),1e-6); % force balance bzbble volume = v_fb
</pre><pre class="language-matlab">so(i) = ((((((3/(4*pi)) ^ (1/3) * (v_fb(i)*(1/3)))*2) ^2)/4)-((D_or^2)/4)^0.5);
ub(i) = v_fb(i)/(pi*((((3/(4*pi)) ^ (1/3) * (v_fb(i)*(1/3)))*2) ^2));
yo = [so(i); ub(i)]; % the initial values for the function
</pre><pre class="language-matlab">tspan = [0 10];%[0 10];
[tdet,ysol] = ode45(@(t,y) scarg1(t,y,v_fb(i),v_rate(i)),tspan,yo)
% I need to find the tdet for a particular value of ysol ?
</pre><pre> end</pre><p>%v_rate = v_rate.*10^6 ;
%v_fin = v_fin.*10^6 ;</p><p>%plot (v_rate,v_fin,'Marker','o','LineStyle','-.')
%title('Scargiali for Metal Alloys')
%xlabel('Flow rate (cm^3/s)')
%ylabel('Bubble Volume (cm^3)')
end</p><p>function F1 = scarg(x,v_rate)</p><pre> g= 9.81;
sig= 0.072;
D_or= 13.78e-03; % Orifice Diameter
denliq= 998;
vis= 8.9e-4; %Dynamic Viscosity of the liquid (Pa.s)
dengas= 1.225;
theta= 80; % The contact angle</pre><pre> F1 = (((pi/2)*(D_or^2)*sig*((4*pi/(3*x))^(1/3)))-((0.5*(v_rate^2)*denliq*(x^(-2/3)))/(12*pi*((3/(4*pi))^(2/3))))-(g*(denliq-dengas)*x)-(dengas*v_rate*(4*v_rate/(pi*(D_or^2)))))
end</pre><pre> function F2 = scarg1(t,y,v_fb,v_rate)</pre><pre> g= 9.81;
sig= 0.072;
D_or= 13.78e-03; % Orifice Diameter
denliq= 998;
vis= 8.9e-4; %Dynamic Viscosity of the liquid (Pa.s)
dengas= 1.225;</pre><pre> s=y(1);
vel=y(2);
M = 1.225* ((4/3)*pi*((s/1.4)^3));
uliq = 2*(v_fb/(pi*(s/0.7)^2));</pre><pre> F2(1) = vel ; % function one for the velocity (ds/dt)
F2(2) = ((-(vel-uliq)*(0.5*denliq*v_rate)+ ((s/0.7) ^3)*pi*(denliq-dengas)*g/6)+(dengas*v_rate*(4*v_rate/(pi*(D_or^2))))+ (-0.5*2.65*denliq*((vel-uliq)^2)*(pi*((s/0.7)^2)/4))-(pi*D_or*sig)/M);
% function 2 for acceleration (du/dt)</pre><pre> % F2 = F2';</pre><pre> end</pre><p>The error I get is</p><p>rror using odearguments (line 90)
@(T,Y)SCARG1(T,Y,V_FB(I),V_RATE(I)) must return a column vector.</p><p>Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn,
...</p><p>Error in mainScarg (line 23)
[tdet,ysol] = ode45(@(t,y) scarg1(t,y,v_fb(i),v_rate(i)),tspan,y</p>Jaunty Josehttps://de.mathworks.com/matlabcentral/profile/authors/11527892-jaunty-josetag:de.mathworks.com,2005:Question/3727682017-12-13T15:49:11Z2017-12-13T17:06:48ZHow can I plot multiple graphs from one set of table data, separated by NaN?<p>I have a table as below:
M=</p><pre class="language-matlab">NaN NaN
2 3
NaN NaN
NaN NaN
15 6
6 7
3 12
38 17
9 59
NaN NaN
10 129
11 34
9 5
NaN NaN
NaN NaN
NaN NaN
</pre><p>Goal: I am trying to plot graphs from each set of data, that is separated by the NaNs</p><p>E.g. for the data below a graph with x=2, y=3
Then a graph with x=15, 6, 3, 38, 9, y=6, 7, 12, 17, 59 respectively</p><p>Overall goal: to find the slope of each set of data and plot the slopes as a frequency distribution</p><p>Thank you!</p>Shravani Kakarlahttps://de.mathworks.com/matlabcentral/profile/authors/6948646-shravani-kakarlatag:de.mathworks.com,2005:Question/3725492017-12-12T12:23:34Z2017-12-13T17:06:24Zwhy calculation time become slow when I use mex file?<p>When I use mex file on matlab, calculation time become too slow. Although c-compiler is faster than matlab.
Why this situation was occurred?</p><p>Let's show data of the situation.</p><p>here is the calculation time of matrix-vector product(dimension is 16000 and 32000).
my PC is Macbook (Intel Core i7 2.5GHz, 16GB memory, Mac OS High Sierra version 10.13.1)</p><p>Matlab using mex file</p><ul><li>dimension, time</li><li>16000, 6.7009 sec</li><li>32000, 4.8024 sec
#include "mex.h"
/* The computational routine */
void MatPro(double *x, double *y, double *z, mwSize m, mwSize n)
{
int i;
int j;</li></ul><pre> /* main program */
for(i=0;i<m;i++){
z[i]=0;
for(j=0;j<m;j++){
z[i]=z[i]+x[m*j+i]*y[j];
//z[i]=fma(z[i],x[m*j+i],y[j]);
}
}
}
/* The gateway function */
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
double *in1; /* input scalar */
mwSize n; /* size of matrix */
mwSize m;
double *in2;
double *out; /* output matrix */</pre><pre> /* get the value of the input */
in1 =mxGetPr(prhs[0]);</pre><pre> /* create a pointer to the real data in the input matrix */
in2 =mxGetPr(prhs[1]);</pre><pre> /* get dimensions of the input matrix */
m = (mwSize)mxGetM(prhs[1]); //GYO
n = (mwSize)mxGetN(prhs[1]); //RETU
/* get dimensions of the input matrix */</pre><pre> /* create the output matrix */
plhs[0] = mxCreateDoubleMatrix(m,n,mxREAL);</pre><pre> /* get a pointer to the real data in the output matrix */
out = mxGetPr(plhs[0]);</pre><pre> /* call the computational routine */
MatPro(in1,in2,out,m,n);
}</pre><p>This is c file to calculate matrix-vector product using mex file.</p><p>On the other hand, Matlab</p><ul><li>dimension, time</li><li>16000, 2.1798 sec</li><li>32000, 8.898 sec</li></ul><pre class="language-matlab">a=rand(16000)*rand(16000,1);
</pre><p>Furthermore, when I use c-compiler like</p><pre class="language-matlab">clang matrix_vecter_product_file.c
</pre><p>the calculation time is</p><ul><li>dimension, time</li><li>16000, 0.93364 sec</li><li>32000, 3.67412 sec</li></ul><p>According to the data, we can see c-compiler is much faster than matlab, matlab using mex file is too slow comparing to the others.</p><p>I think matlab using mex file should be faster than matlab because of the time of c-compiler and matlab.</p><p>However, the time of matrix-vecor product on matlab using mex file is too slow. Why is that?</p>hotaka yagihttps://de.mathworks.com/matlabcentral/profile/authors/10222408-hotaka-yagitag:de.mathworks.com,2005:Question/3717052017-12-07T15:59:36Z2017-12-13T17:00:28ZHow to visualize the GUI of VST Plugin?<p>I'm loading a VST3 64 bits called (VOXENGO SPAN) into MATLAB following the example:</p><p><b>MATLAB Example:</b>
https://www.mathworks.com/help/audio/ref/loadaudioplugin.html</p><p><b>SPAN:</b> <a href = "http://www.voxengo.com/product/span/">http://www.voxengo.com/product/span/</a></p><p>After loaded, I got this:</p><pre class="language-matlab">hostedSourcePlugin =
</pre><pre> VST3 plugin 'SPAN' 2 in, 2 out</pre><pre> Meterin: 'dBFS'
Bypass: 'Off'
Program: 'Default'</pre><p>Now, I want to see the graphical interface of this VST (GUI) like when I use it in a Digital Audio Workstation (DAW): Pro Tools, Logic, etc...</p><p>Finally, I would like to load a audio file and pass through this plugin and listen the processed audio.</p><p>Any help?</p>Nycholas Maiahttps://de.mathworks.com/matlabcentral/profile/authors/8458420-nycholas-maiatag:de.mathworks.com,2005:Question/3727582017-12-13T14:31:25Z2017-12-13T16:56:02Zfsolve for 2 equation with 2 variables<p>Here is my function, in order to shorten the expression here I add <b>A</b> and <b>B</b>, but in my original function they are inside <b>F(1)</b> and <b>F(2)</b> (i.e. that is not the problem), this is the error I get: Objective function is returning undefined values at initial
point.</p><pre class="language-matlab">function F = myfun(x)
N=32;
K=5;
s=1;
b=0.1;
P=5;
A=-2*s^4*x(1)*N+2*s^4*x(1)*K+3*s^2*x(2)*log(2);
B=sqrt(8)*x(2)*s^2*log(2);
g=exprnd(1,1,N-K);
F(1) = sum((g.*(1-b*x(1))/(x(2)*log(2)))-1./g)+(N-K)*((A+sqrt(A^2-B^2))/((4*s^2/sqrt(8))*B))-N*P;
F(2) = b*(sum(log2((g*(1-b*x(1)/x(2)*log(2))))))-(N-K)*log2(1+(2*A^2+2*A*sqrt(A^2-B^2)-B^2)/((4/sqrt(8))*B*(A+(4/sqrt(8))*B+sqrt(A^2-B^2))));
end
</pre>Miroslav Mitevhttps://de.mathworks.com/matlabcentral/profile/authors/10363098-miroslav-mitevtag:de.mathworks.com,2005:Question/3727882017-12-13T16:54:36Z2017-12-13T16:54:36ZMultiple identical functions created for a reusable subsystem<p>I am using MATLAB 2014a with Simulink and Embedded Coder.
I have a subsystem that is part of a user-defined library in Simulink. Function packaging is set to "Reusable function" with a user specified function name. Let's call that Subsystem_LIBA.
Now, I am trying to generated code (using embedded coder) for a Simulink subsystem that uses the library block (Subsystem_LIBA) 2 times. The generated code doesn't seem to be reusing the generated function for "Subsystem_LIBA". It seems to be generating two functions that are identical in content for the reusable subsystem. I ensured that the data type and signal dimension input to my library block are the same.
Why doesn't Embedded Coder reuse the generated function code?</p>Amr Nagatyhttps://de.mathworks.com/matlabcentral/profile/authors/10262667-amr-nagatytag:de.mathworks.com,2005:Question/3725512017-12-12T12:35:04Z2017-12-13T16:48:53ZWhat can I write in a MATLAB function block in Simulink?<p>Hi
I am working with Simulink. I wrote a function in Matlab that basically does a circular shift, and I wanted to put it into Simulink by using the MATLAB function block. The thing is that if I write</p><pre class="language-matlab">function y= shift_with0(u,s)
y = circshift(u,s);
y(1:s)=0;
end
</pre><p>no problem and everything is working. But, I wanted to allow as inputs also vectors, so I wrote this function</p><pre class="language-matlab">function y= shift_with0(u,s)
if isvector(s)
pm=sign(s);
inegatif = sum(pm(:)==-1);
s = inegatif;
end
y = circshift(u,s);
y(1:s)=0;
end
</pre><p>In Matlab is working, but the Simulink block not. So, I assume that is the "if" part that Simulink does not accept. In general, could someone clarify for me what I can write/not write in a MATLAB function block?
Thanks</p>Mariahttps://de.mathworks.com/matlabcentral/profile/authors/5027828-mariatag:de.mathworks.com,2005:Question/3723612017-12-11T18:36:15Z2017-12-13T16:47:35ZIs it possible to Create Custom Arduino Add-On Device, Library, or Code for Arduino DUE?<p>I wrote a custom Arduino Add-On following documentation (Create Custom Arduino Add-On Device, Library, or Code) that works very well on Arduino UNO and MEGA.
When I update my Add-On on Arduino DUE using the following command:</p><pre class="language-matlab">a = arduino('COM10', 'due', 'Libraries', 'ExampleAddon/HX711');
</pre><p>an error occurs: <b>Cannot program board Due (COM10). Please make sure the board is supported and the port and board type are correct. For
more information, see Arduino Hardware Troubleshooting.</b></p><p>The arduino board is original and works well when using Matlab Support package and libraries such as SPI or I2C.
If I upload the Arduino server with "arduinosetup" command, no errors occur and my library is detected by "listArduinoLibraries", but when I create an arduino object, Matlab starts uploading server again without my library.
I thought there's some special code that must be included in C++ header file, but I can't find anything in documentation. In Matlab support package description this functionality seems to be supported.</p>NICHOLAS GIACOBONIhttps://de.mathworks.com/matlabcentral/profile/authors/7779346-nicholas-giacobonitag:de.mathworks.com,2005:Question/3727832017-12-13T16:46:26Z2017-12-13T16:48:57ZHow can I connect Cassandra DB using its JDBC driver in Matlab?<p>Hello,
I am pretty new to Matlab. I have a task to connect the Cassandra cluster using Matlab. I do have an access to Cassandra JDBC driver jar, therefore I wrote a test script to test if I could connect to cluster. Where am I going wrong. Thanks.</p><pre class="language-matlab">function cassandra_matlab
cassandra_jdbc_path='C:/Users/adm_lokal/Downloads/cassandra-jdbc-wrapper-3.1.0-SNAPSHOT.jar';
javaaddpath(cassandra_jdbc_path)
datasource='cassandra';
username='';
password='';
driver='org.apache.cassandra2.cql.jdbc.CassandraDriver';
url='jdbc:cassandra://127.0.0.1:9042/project_fvag_dev';
</pre><pre class="language-matlab">%connecting to cassandra cluster
conn=database(datasource,username,password,driver,url);
print('connected!!!');
selectquery='SELECT * from project_fvag_dev.zeit2_schnellemessrate_6dof_033 LIMIT 5';
data=select(conn,selectquery);
close(conn);
</pre><p>Output:
Error using database (line 158)
Java exception occurred:
com.google.common.util.concurrent.ExecutionError: java.lang.ExceptionInInitializerError</p><pre> at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)</pre><pre> at com.google.common.cache.LocalCache.get(LocalCache.java:3932)</pre><pre> at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3936)</pre><pre> at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4806)</pre><pre> at com.github.adejanovski.cassandra.jdbc.CassandraDriver.connect(CassandraDriver.java:102)</pre><pre> at com.mathworks.toolbox.database.DrivJDBC.connect(DatabaseConnection.java:30)</pre><pre> at java.sql.DriverManager.getConnection(Unknown Source)</pre><pre> at java.sql.DriverManager.getConnection(Unknown Source)</pre><pre> at com.mathworks.toolbox.database.DatabaseConnection.<init>(DatabaseConnection.java:151)</pre><p>Caused by: java.lang.ExceptionInInitializerError</p><pre> at com.github.adejanovski.cassandra.jdbc.SessionHolder.createSession(SessionHolder.java:137)</pre><pre> at com.github.adejanovski.cassandra.jdbc.SessionHolder.<init>(SessionHolder.java:83)</pre><pre> at com.github.adejanovski.cassandra.jdbc.CassandraDriver$1.load(CassandraDriver.java:68)</pre><pre> at com.github.adejanovski.cassandra.jdbc.CassandraDriver$1.load(CassandraDriver.java:65)</pre><pre> at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3522)</pre><pre> at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2315)</pre><pre> at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2278)</pre><pre> at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2193)</pre><pre> ... 8 more</pre><p>Caused by: java.lang.IllegalStateException: Detected Guava issue #1635 which indicates that a version of
Guava less than 16.01 is in use. This introduces codec resolution issues and potentially other
incompatibility issues in the driver. Please upgrade to Guava 16.01 or later.</p><pre> at com.datastax.driver.core.SanityChecks.checkGuava(SanityChecks.java:62)</pre><pre> at com.datastax.driver.core.SanityChecks.check(SanityChecks.java:36)</pre><pre> at com.datastax.driver.core.Cluster.<clinit>(Cluster.java:67)</pre><pre> ... 16 more</pre><p>Error in cassandra_matlab (line 11)
conn=database(datasource,username,password,driver,url);</p>Jasim Waheed Ansarihttps://de.mathworks.com/matlabcentral/profile/authors/9077663-jasim-waheed-ansaritag:de.mathworks.com,2005:Question/3727822017-12-13T16:46:14Z2017-12-13T16:46:14ZHow to define sequence of dates between to dates on monthly time step?<p>Hello,
I want to generate sequence of dates between two dates on monthly time step, however, couldnt figure a way out. I have tried various options such as datenum, datestr, datetime etc but could not solve my problem. Here is a sample of one trial.</p><pre class="language-matlab">StartDate= datetime(1981,01,01);
EndDate=datetime(2010,12,31);
formatOut='yyyy-mm';
Date=StartDate:EndDate;
Date=datetime(Date,formatOut);
</pre><p>I know it won't work as the number of the argument are wrong. but I want the date in the following format. Any help would be highly appreciated.</p><pre class="language-matlab">Jan-1981
Feb-1981
Mar-1981
-------
--------
Dec- 2010
</pre>Hydrohttps://de.mathworks.com/matlabcentral/profile/authors/5628601-hydrotag:de.mathworks.com,2005:Question/3727642017-12-13T15:13:33Z2017-12-13T16:39:49ZMATLAB Editor bounce left when scrolling<p>I have this weird problem since changing to either R2017b. I wonder how can I solve this because it is getting really annoying now</p>Sharahhttps://de.mathworks.com/matlabcentral/profile/authors/4708077-sharahtag:de.mathworks.com,2005:Question/3727812017-12-13T16:38:24Z2017-12-13T16:38:24ZProblem with Arduino and Matlab <p>Greetings, I am currently working on a project where I acquire sensor data, with the Arduino NANO board and the Matlab software (through a GUI). When the board is connected to my PC cable everything works very well; but the goal of my project is to do it wirelessly. This is where I have the problem that I can not get Matlab to recognize the Arduino with the hardware that I add,</p><p>it work wit the wire to PC</p><pre> a = arduino('COM18','Nano');</pre><p>But wen i use the rf system</p><p>this is a type of error
"Cannot program board Nano3 (COM18). Please make sure the board is supported and the port and board type are
correct."</p><p>I am using two systems: two Xbees or two 3DRbut nothing works</p>Yefferson Bohorquezhttps://de.mathworks.com/matlabcentral/profile/authors/11092260-yefferson-bohorqueztag:de.mathworks.com,2005:Question/3288392017-03-08T20:33:39Z2017-12-13T16:37:27ZSyncing Matlab and Github Branches<p>Hello,</p><p>I am wondering how to sync branches between the Matlab and Github branch manager tools, and what the proper workflow for creating branches with these tools is?</p><p>I recently created a repository on Github then used Matlab's Git integration tools to clone this repository on my local machine. I successfully tested the basic Git features using the Matlab GUI and was even able to implement branching in my local repo using Matlab's branch manager tool.</p><p>However, now I am having trouble figuring out how to sync the branches created in Matlab's branch manager tool with the branching tools on Github and vice versa. I have created a branch in my local repo using the Matlab branch manager, however when I push my local repo back to the remote Github repo the branch I made using the Matlab GUI does not appear on Github. Conversely, if I create a branch on Github and then fetch the remote repo to my local repo, I am unable to select the branch created on Github in the Matlab branch manager tool. Is Matlab able to sync branching done with these two tools?</p><p>Thanks, Robert</p>repritchett92https://de.mathworks.com/matlabcentral/profile/authors/7985009-repritchett92tag:de.mathworks.com,2005:Question/3727802017-12-13T16:36:39Z2017-12-13T16:36:39ZExternal mode for TI board ezdsp tms320f28335<p>Dear all,</p><p>I worked on TI board ezdsp tms320f28335
I install CSSV7 and matlab2011b (32 bit)
I make an example of blinking diode and its worked very well. Now I want to make the monitoring of signals in scope in simulink and I want to make online the variation of control parameters with simulink: I followed exactly the steps of external mode configuration available in mathwork website but every time I receive error.</p><p>steps:
1) Steps which I do (matlab 2011 b):
Hardware implementation: I define the target as follow
I select Device vendor: Texas instrument and Devise type: C2000</p><p>2) Code generation : here I don’t know how doing but I followed the example (I make gmake as make command)</p><p>3) Interface: I select TIC28X and I select external mode In Target interface exist two option: I choose serial-win32</p><p>And I try to build but each time error
Thanks you for your help</p>Mohamed Amine Fnaiechhttps://de.mathworks.com/matlabcentral/profile/authors/10980953-mohamed-amine-fnaiech