https://jp.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — 新規の質問2020-02-20T12:03:00Ztag:jp.mathworks.com,2005:Question/5065952020-02-20T11:29:50Z2020-02-20T11:59:59ZPass variables from callbacks to custom functions in a GUII created a gui with two buttons that allow you to load the stl files and record the mesh on axes. I wanted to create a custom function to be called every time the changes to the mesh are displayed in order to refresh the display. I'm having trouble passing the loaded data to the function, when I run it I get the error message:
"Object must be a figure or one of its child objects"
Can anyone tell me what am I wrong? Thank you!
This is the callbacks of the button:
function OpenSTLfileButtonPushed(app, event)
[file, pathToFile] = uigetfile({'*.*','All Files'},'Select .STL File');
[f,v,N] = stlread(strcat(pathToFile,file));
v_min_x = min(v(:,1));
v_min_y = min(v(:,2));
v_min_z = min(v(:,3));
v(:,1) = v(:,1) - v_min_x;
v(:,2) = v(:,2) - v_min_y;
v(:,3) = v(:,3) - v_min_z;
[f2,v2] = remove_duplicate_vertex(f,v);
edgeUnici = UniqueEdgeSearch(f2);
handles.f2 = f2;
handles.v2 = v2;
guidata(app, handles);
refresh(app, handles);
end
And and this is the custom function:
function refresh(app,handles)
disp("ciao");
f2 = handles.f2;
v2 = handles.v2;
stlPlotGUI(v2,f2,'C','k',app.UIAxes);
hold(app.UIAxes, 'on' );
endGabriele Rossihttps://jp.mathworks.com/matlabcentral/profile/authors/10324189-gabriele-rossitag:jp.mathworks.com,2005:Question/5060072020-02-17T16:53:42Z2020-02-20T11:58:27Zmy datatip disappears in app GUI when i add another y axisI have one xaxis and two yaxis,
namely yaxis left and yaxis right
the datatip disappears when I add the yaxis right,
Is there a solution for this?Prajwal Venkateshhttps://jp.mathworks.com/matlabcentral/profile/authors/13333755-prajwal-venkateshtag:jp.mathworks.com,2005:Question/5006552020-01-16T20:54:17Z2020-02-20T11:56:04ZTraining NN with single precision data on GPUI am trying to use fitnet to train a network on my GPU using single-precision input data (X and T). However, this always returns an error, which starts with:
"Error using nnGPUOp.bg (line 134) Variable 'perfs1' changed type. Consider renaming variable on left hand side of assignment."
This only seems to be a problem when using single-precision data AND the GPU. When I train using double-precision on GPU, it works fine, and when I use single- or double-precision data on the CPU, it also works fine.
Anyone found a way around this?Cameron Leehttps://jp.mathworks.com/matlabcentral/profile/authors/6254307-cameron-leetag:jp.mathworks.com,2005:Question/5055942020-02-15T06:14:34Z2020-02-20T11:54:19Zclustering nearest 5 elements of a dataI have 36 points I need to find the nearest 5 elements of each point and cluster it in a group. Then there is a total of 36 clusters will get. The points are in the 'core' and I need to find the nearest elements from the 'data'. How can I do that? Please help me.
clc;
clear;
data=xlsread('Pimaxl.xlsx');
Si=size(data);
asc=sort(data);
num = numel(data);
diff=unique(asc);
core1=maxk(diff,12);
core2=mink(diff,12);
n = numel(diff(:));
midpoint = ceil(n/2);
core3 = diff(midpoint-5:midpoint+6);
cor=[core1 core2];
core=[cor core3];
sreelekshmi mshttps://jp.mathworks.com/matlabcentral/profile/authors/13185611-sreelekshmi-mstag:jp.mathworks.com,2005:Question/4909792019-11-14T00:05:53Z2020-02-20T11:47:09Z Undefined function or variable 'replaceLayer'. layers = [
imageInputLayer([28 28 1],'Name','input')
convolution2dLayer(5,20,'Name','conv_1')
reluLayer('Name','relu_1')
additionLayer(2,'Name','add')
fullyConnectedLayer(10,'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classoutput')];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'input','add/in2');
>> larray = [batchNormalizationLayer('Name','BN1')
leakyReluLayer('Name','leakyRelu_1','Scale',.02)];
newlgraph = replaceLayer(lgraph,'relu_1',larray);
Undefined function or variable 'replaceLayer'.
Why in some computers works and in other it does not works and they are the same version with the same toolboxes??carlos arizmendihttps://jp.mathworks.com/matlabcentral/profile/authors/8139048-carlos-arizmenditag:jp.mathworks.com,2005:Question/4860092019-10-17T23:08:52Z2020-02-20T11:46:33ZSimulink 2019 - external modeI upgraded 2018a, to 2019b. I use a model that is cross compiled and deployed. I then use "connect to target" in external mode to interact with the hardware.
My install of Simulink 2019b seems to be missing "external" as a pull down option. I see "Normal" , "Accelerator", "Rapid Accelerator". But no "External"
I'm not sure why... did I not install a necassary add-on?Jason Gauthierhttps://jp.mathworks.com/matlabcentral/profile/authors/10503322-jason-gauthiertag:jp.mathworks.com,2005:Question/5066002020-02-20T11:45:31Z2020-02-20T11:45:31ZDFT using matlab functionIn case a off-nominal signal is processed using nominal frequency based fft algorithm, the peak value of the magnitude of fft is still at the frequency index or bin pertaining to the nominal value (though the amplitude is different and the side lobes also have an amplitude which is not seen when the signal has a nominal value of frequency). Why does the frequency index not change even though the frequency is no longer the nominal value. How can i visualize this in matlab using the fft function. mir khadimhttps://jp.mathworks.com/matlabcentral/profile/authors/9964742-mir-khadimtag:jp.mathworks.com,2005:Question/5065972020-02-20T11:38:56Z2020-02-20T12:03:00ZError importing data from .CSVHello,
I have matlab script that calls a function, which then reads through a series of .csv files. At the moment, I've been given old .csv files saved from October, 2019 that are succesfully read-in and processed. If I were to take those same .csv files that were saved in October of 2019, and simply resave the file(s) without any change, the matlab script will break and give me the following error seen below:
Index exceeds the number of array elements (7).
Side note: Other things I've noticed... If I change the file name outside of opening the actual file, the script will work fine. But, If I were to open the .csv file, change the name and then save it and close it... that would break the script. Lastly, I've noticed when I do resave the .csv file... the .csv file gets compressed a considerable amount (2000 kb -> 1,500 kb), but have verified the file properties are .csv. So i'm unsure what the issue might be!!
I've added an image of the excel file before and after I save it. Untitled is the recently saved excel file while the titled file is the old version. It's clearly reformatting the excel file but I'm not sure how to prevent this from happening.
Thanks in advance.
John Andrewhttps://jp.mathworks.com/matlabcentral/profile/authors/11970563-john-andrewtag:jp.mathworks.com,2005:Question/5065992020-02-20T11:44:46Z2020-02-20T11:44:46ZHow to apply one sample Kolmogorov-Smirnov against a Rician distribution?I want to apply a one-sample Kolmogrov-Smirnov test a vector "mydata" of [1,5000] against the Rician distribution to see if it follows a Rician distribution or not. I am not sure if I am doing it correctly. Can anybody confirm me if is it correct or not?
pdData=fitdist(mydata' , 'Rician');
cdfData=cdf ( 'Rician', mydata', pdData.s, pdData.sigma);
testcdf = [mydata',cdfData];
[h,p]=kstest(mydata','CDF',testcdf);yusra Chhttps://jp.mathworks.com/matlabcentral/profile/authors/8951940-yusra-chtag:jp.mathworks.com,2005:Question/5065982020-02-20T11:39:44Z2020-02-20T11:39:44Zseven level diode clamped inverterhow to design a three phase seven level diode clamped multilevel inverter based on space vector modulation technique?Swarupananda Mohantyhttps://jp.mathworks.com/matlabcentral/profile/authors/16738197-swarupananda-mohantytag:jp.mathworks.com,2005:Question/5065612020-02-20T08:27:24Z2020-02-20T11:38:55ZUsing nested for loops to plot multiple approximations of Eulers method%%Improved Eulers
clear all;
F=@(x,y) -cos(x*y);
Xnum(1)=1;
Ynum(1)=3;
Xf=2;
Ypred(1)=Ynum;
figure(2)
hold on
for hstep = 1/16:1/2:1/128
Numsteps=(Xf-Xnum(1))/hstep;
for k = 1:Numsteps:1000
Xnum(k+1) = Xnum(k) + hstep;
Ypred(k+1)= Ynum(k)+hstep*F(Xnum(k),Ynum(k));
Ynum(k+1) = Ynum(k) + hstep*0.5*(F(Xnum(k),Ynum(k))+F(Xnum(k+1),Ypred(k+1)));
end
plot(Xnum,Ynum)
endBenhttps://jp.mathworks.com/matlabcentral/profile/authors/14562219-bentag:jp.mathworks.com,2005:Question/5040542020-02-06T14:36:53Z2020-02-20T11:36:51Zcreate video of position from matrixI would like to plot the evolution of the positions of the nodes of my graph by extracting such informations from a matrix. I have tried with the following code:
nodesmatrix1=[100.930486523955,100.930575750737,100.930665005716,100.930754288889;...
0.537217125673953,0.537268640710124,0.537320172025868,0.537371719619598;...
0,0,0,0;...
-50,-50,-50,-50;...
87.6769342598990,87.6770372900756,87.6771403528114,87.6772434481033;...
0,0,0,0;...
-50,-50,-50,-50;...
-86.6025000000000,-86.6025000000000,-86.6025000000000,-86.6025000000000;...
0,0,0,0;...
-86.8313497413550,-86.8331653236005,-86.8349807356126,-86.8367959772504;...
50.8442720217766,50.8412459247854,50.8382199043914,50.8351939608639;...
202.668269119694,202.667265160646,202.666261247557,202.665257380501;...
0.313749463634742,0.317367162195871,0.320984737502106,0.324602189246993;...
-100.083107035647,-100.083114813157,-100.083122465259,-100.083129991967;...
202.668270199404,202.667266238431,202.666262323417,202.665258454434;...
87.4480844077347,87.4463715232573,87.4446586199985,87.4429456981209;...
50.8504867629172,50.8536751827095,50.8568634493359,50.8600515625364;...
202.668269910080,202.667265949606,202.666262035091,202.665258166609];
edge = [1 2;2 3;3 1;1 4;2 5;3 6];
type = [1; 1; 1; -1; -1; -1];
structure = VideoWriter('structure.avi');
open(structure);
for i = 1:4
EdgeTable = table(edge,type, ...
'VariableNames',{'EndNodes','type'});
structure=graph(EdgeTable);
nodestep=nodesmatrix1(:,i);
nodestepmatrix=[nodestep(1:3:length(nodestep))'; nodestep(2:3:length(nodestep))'; nodestep(3:3:length(nodestep))'];
p=plot(structure,'XData', nodestepmatrix(1,:), 'YData', nodestepmatrix(2,:),'ZData',nodestepmatrix(3,:));
frame = getframe(gcf);
writeVideo(structure,frame);
end
close(structure);
But it doesn't work. I obtain only the plot of the last column of nodesmatrix1.
What is wrong?
Gaetano Pavonehttps://jp.mathworks.com/matlabcentral/profile/authors/7331525-gaetano-pavonetag:jp.mathworks.com,2005:Question/5065962020-02-20T11:30:32Z2020-02-20T11:30:32ZWhy a great software such as Matlab does not support some ONNX operators and where and when can I find mfiles for replacing the placeholder layers?Even Matlab R2019b does not support, some simple ONNX operators such as ‘Gather’, ‘shape’, ‘Resahpe’ and so on. As a results, the Matlab users have been encountered a serious problems for importing the new ONNX models. It is not good for Matlab as a great software. Does anyone can help me on this issue or is there any mfile for replacing unsupported ONNX operators?Hossein Khodabakhshihttps://jp.mathworks.com/matlabcentral/profile/authors/9362551-hossein-khodabakhshitag:jp.mathworks.com,2005:Question/4993112020-01-07T19:01:43Z2020-02-20T11:30:24ZAlternative Error Histogram Plot ?Hi guys!
I'd like to plot an error histogram for my thesis, however the function ploterrhist cannot be used in a subplot which is very strange. I'd like to obtain the same or similar result including the x-axis and y-axis labeling and most importantly the x-axis scale as shown in the following picture.
Can anyone help ? Thank you ! Aladin Djuherahttps://jp.mathworks.com/matlabcentral/profile/authors/11364632-aladin-djuheratag:jp.mathworks.com,2005:Question/5064942020-02-19T21:21:40Z2020-02-20T11:29:19ZUsing ODE-45 with control input in state equation updating on each loopHello,
I have an issue with my code and I cannot figure out how to solve this issue.
I have a system of equations and the 2 control inputs is constantly updating on each loop. The control inputs have an initial condition of 0.
After the first iteration the control inputs are evaluated using simple algebra of the values of some states.
This is causing me to get all 0's for x(5) and x(6)and these values are needed to calculate u1 and u2 so in return my control values u1 and u2 are also incorrect.
Please help!
function dxdt= odefcn(t,x,u1,u2)
a=4.31e-3;b=1.02e-14;c1=3.41e-10;
f=4.12e-2;g=1.5e-2;h=2.02e1;
k2=6e-1;k3=k2;k1=8e-1;po=2e-11;
s1=1.2e4;s2=7.5e8;delta=1.2e-2;
gamma=9e-1;
r=.5;
dxdt = zeros(7,1);
dxdt(1)= a*x(1)*(1-(b*x(1)))-(c1*x(4)*x(1))-k3*x(3)*x(1);
dxdt(2)=-(delta*x(2))-(k2*x(3)*x(2))+s2;
dxdt(3)=-(gamma*x(3))+u2;
dxdt(4)=(g*(x(1)/h+x(1))*x(4))-r*x(4)-(po*x(4)*x(1))-k1*x(4)*x(3)+s1*u1;
dxdt(5)=u1;
dxdt(6)=u2;
dxdt(7)=-1;
%% Run simulatiom
clc
clear
close all
T=60;
tspan = 0:1:T;
x0 = [5e9 1e8 0 1e9 0 0 60];
u1=0; u2=0;
%variable paramaters
d=.75;duty_cycle=.4;gamma=9e-1;
u1bar=50; u2bar=1;
t=1:1:61;
for k=1:length(t)
T(k)= (61-k);
Da(k)=(d*duty_cycle*T(k)*u1bar);
Db(k)=[d*duty_cycle*T(k)*u2bar];
D1=transpose(Da);
D2=transpose(Db);
u11(k)=(D1(k)-x(k,5)/(gamma*x(k,7)));
u22(k)=(D2(k)-x(k,6)/(gamma*x(k,7)));
u1a=transpose(u11);
u2a=transpose(u22);
u1(k)= min(u1bar,u1a(k));
u2(k)=min(u1bar,u2a(k));
end
[t,x]=ode45(@(t,x) odefcn(t,x,u1,u2),tspan,x0);
Mohamed AL Sagerhttps://jp.mathworks.com/matlabcentral/profile/authors/14519755-mohamed-al-sagertag:jp.mathworks.com,2005:Question/5065892020-02-20T11:08:41Z2020-02-20T11:28:47ZAdd value in a matrixHi, I need to add a row of values to an array, taking into account the last row of my array (once sorted) I want the next row to show a number starting at 1 that is related to the previous row. Here is an example to try to explain it better
% First matrix
Z = [255 1 0 255 255 255 1
30 51 51 30 29 29 21
49 51 52 48 51 52 48
-5 4 4 -5 -4 -4 4];
% Orderly matrix in the 4th row
ZORD = [255 255 255 255 1 0 1
30 30 29 29 21 21 21
49 48 51 52 51 52 48
-5 -5 -4 -4 4 4 4];
% So far I know how to do it, but this is what I put in now is what
% I only know how to do with a for-loop but for my data size it is not very operational.
ZFIN = [255,255,255,255,1,0,1;
30,30,29,29,21,21,21;
49,48,51,52,51,52,48;
-5,-5,-4,-4,4,4,4;
1 1 2 2 3 3 3]
If someone knows how to do the last step I would be very grateful, thank you very muchAlajendro Fernándezhttps://jp.mathworks.com/matlabcentral/profile/authors/14262385-alajendro-fernandeztag:jp.mathworks.com,2005:Question/5065942020-02-20T11:27:59Z2020-02-20T11:27:59ZHow can I add Matlab GUI to web app?I will do final project. I don't know How can I add Matlab GUI , Matlab Simulink to web app?Nazlican Atasoyhttps://jp.mathworks.com/matlabcentral/profile/authors/14977538-nazlican-atasoytag:jp.mathworks.com,2005:Question/5065622020-02-20T08:28:48Z2020-02-20T11:27:07Zfor loop for matrixesi have a for loop inside a function and one of the input is a matrix of 44x12 (FC_in) the rest is just a value
i am doing sth work and i am getting error :
Error in Tabelle_43 (line 18)
[ f_pl ] = f_pl_Tabelle_43( T_43, V_H_WS, P_WP_KN, FC_in, FC ) ;
my inputs + function and below the code
T_43 = 1 ;
V_H_WS = 1 ;
FC = 2 ;
[ f_pl ] = f_pl_Tabelle_43( T_43, V_H_WS, P_WP_KN, FC_in, FC ) ;
function [ f_pl ] = f_pl_Tabelle_43( T_43, V_H_WS, P_WP_KN, FC_in, FC )
for i = 1 : 12
for j = 1 : length(FC_in)
if T_43 == 1
% Kleinflaeche Waermeabgabe V_H_WS = 0
if V_H_WS == 0 && FC_in(j,i) < 0.5 && FC_in(j,i) > 0
f_pl(j,i) = 0.588 ;
elseif V_H_WS == 0 && FC_in(j,i) >= 0.5 && FC_in(j,i) < 1
f_pl(j,i) = 0.588+0.822.*(FC-0.5) ;
% Kleinflaeche Waermeabgabe 0 < V_H_WS < 30*P_WP_KN
elseif V_H_WS > 0 && V_H_WS < 30*P_WP_KN && FC_in(j,i) < 0.5 && FC_in(j,i) > 0
f_pl(j,i) = 0.588+0.01*(V_H_WS./P_WP_KN) ;
elseif V_H_WS > 0 && V_H_WS < 30*P_WP_KN && FC_in(j,i) >= 0.5 && FC_in(j,i) < 1
f_pl(j,i) = 0.177+0.02*(V_H_WS./P_WP_KN)-0.02*FC ;
% Kleinflaeche Waermeabgabe V_H_WS >= 30*P_WP_KN
elseif V_H_WS >= 30*P_WP_KN && FC_in(j,i) < 0.5 && FC_in(j,i) > 0
f_pl(j,i) = 0.888 ;
elseif V_H_WS >= 30*P_WP_KN && FC_in(j,i) >= 0.5 && FC_in(j,i) < 1
f_pl(j,i) = 0.888+0.222*(FC-0.5) ;
else
error('error !')
end
elseif T_43 == 2
% Grossflaechige Waermeabgabe
if FC_in(j,i) < 0.5 && FC_in(j,i) > 0
f_pl(j,i) = 0.974;
elseif FC_in(j,i) >= 0.5 && FC_in(j,i) < 1
f_pl(j,i) = 0.974+0.05.*(FC-0.5);
else
error('error !')
end
else
error('error !')
end
end
end
endAleksandra Ksiezykhttps://jp.mathworks.com/matlabcentral/profile/authors/7645635-aleksandra-ksiezyktag:jp.mathworks.com,2005:Question/5055582020-02-14T21:02:51Z2020-02-20T11:27:02ZDraw this type of figure from given data.the data contains lat long disp(north,east,down) and other quantities but i need figure only for the displacement simillar to the attached figureMITHUN RANAhttps://jp.mathworks.com/matlabcentral/profile/authors/9931094-mithun-ranatag:jp.mathworks.com,2005:Question/5059502020-02-17T14:31:55Z2020-02-20T11:26:56ZWhy does matlab change cos / sin input?Hello,
Something very weird happens when i try to integrate cos / sin functions. Matlab changes te values i put in the cos / sin for example this happens when i want to integrate acceleration (a) to speed (v):
>> syms x
>> a=cos(-2*x+3)
a =
cos(2*x - 3)
How can i avoid this?Wouter van den Wijngaardhttps://jp.mathworks.com/matlabcentral/profile/authors/17195399-wouter-van-den-wijngaardtag:jp.mathworks.com,2005:Question/5058422020-02-16T21:43:50Z2020-02-20T11:25:07Zsound will not play Mac Matlab 2018bHi there, I am working through a brilliant Udeny course in Matlab and am currently working on generating a sound but am finding that this session does not work, even though I have written exactly as specified (I think!)
frequencies = 5000; % Hz
duration = 1; % duration of the sound
amplitude = 1; % loudness
fs = 44100; % Sampling rate
T = 1 / fs ; % Time sampling period
t = 0:T:duration; % time vector
signal = amplitude * cos(2 * pi * frequencies * t);
sound(signal, fs)
Can anyone tell me where I'm going wrong please?Tracey Rochesterhttps://jp.mathworks.com/matlabcentral/profile/authors/13905356-tracey-rochestertag:jp.mathworks.com,2005:Question/5065932020-02-20T11:24:22Z2020-02-20T11:24:22Zhow to substitute sym variables in jacobian matrix with numeric values?
syms x y z
u = -Iscr + Iph - (x * ((exp((Iscr*y)/(n*Vth)))-1)) ...
- ((Iscr*y)/z);
v = Iph - (x * ((exp((Vocr)/(n*Vth)))-1)) - ((Vocr)/z);
w = -Im + Iph - (x * ((exp((Vm + Im*y)/(n*Vth)))-1))...
- ((Vm + (Im*y))/z);
a= jacobian([u;v;w],[x,y,z])
j=subs(a,[x,y,z],[xo,yo,zo]) %% This doesn't work, please explain why and also the alternative to this.Nikhil Shriyanhttps://jp.mathworks.com/matlabcentral/profile/authors/13432877-nikhil-shriyantag:jp.mathworks.com,2005:Question/3834892018-02-19T12:09:54Z2020-02-20T11:17:51Zhi. i am trying to use natsortfile() function to sort filenames in ascending order. error shown is 'undefined variable or function name'. kindlly help.<</matlabcentral/answers/uploaded_files/105322/Capture.JPG>>
Alankrita Asthanahttps://jp.mathworks.com/matlabcentral/profile/authors/11877925-alankrita-asthanatag:jp.mathworks.com,2005:Question/5065922020-02-20T11:17:33Z2020-02-20T11:17:33Zcampare a row value with the next rowHi
I have the following column:
1
1
0
0
0
1
0
1
0
1
I want to campare rows value one by one with the next row ( first with second, second with third ... and ninth with tenth) and check if it changes for 1 to 0, 0 to 0, 0 to 1 and 1 to 1. For each of these conditions, I want to count them. I tried using loop and diff or sign and equations but I could not work out because the results will be similar for two conditions.
Boby Shttps://jp.mathworks.com/matlabcentral/profile/authors/13011252-boby-stag:jp.mathworks.com,2005:Question/5065912020-02-20T11:14:54Z2020-02-20T11:14:54ZHow to solve 3 non-linear equations with 3 unknowns?This is my code with solve,
G= 1000;
T=298;
Iscr = 9.71; %short citrcuit current
Vocr = 6; %Open circuit voltage
Im = 9.4; %MPP current
Vm = 5.5; %MPP coltage
K_Isc = 0.0005;
Vth = 0.8629*10^(-4)*T;
Iph= (G/1000) * Iscr* (1-(K_Isc)* (T-298 ));
n = 1;
%Io =x
%Rs = y
%Rsh = z
syms x y z
u = -Iscr + Iph - (x * ((exp((Iscr*y)/(n*Vth)))-1)) - ((Iscr*y)/z)==0;
v = Iph - (x * ((exp((Vocr)/(n*Vth)))-1)) - ((Vocr)/z)==0;
w = -Im + Iph - (x * ((exp((Vm + Im*y)/(n*Vth)))-1)) - ((Vm + (Im*y))/z)==0;
x0 = [10^-8,0.2,2500];
d = solve([u,v,w],[x,y,z],x0);
But I got this error:
>> fsolve18_2
Error using sym.getEqnsVars>checkVariables (line 87)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in solve18_2 (line 24)
d = solve([u,v,w],[x,y,z],x0);
Nikhil Shriyanhttps://jp.mathworks.com/matlabcentral/profile/authors/13432877-nikhil-shriyantag:jp.mathworks.com,2005:Question/5064872020-02-19T20:28:15Z2020-02-20T11:13:30ZCubic smooth spline plot in 3d for several layersHello I have vectors
iv3,iv28,iv48,iv68,iv133,iv268,iv398 (ilength 83x1 - positive real numbers)
and one vector named strikes (length 83x1 - positive real numbers)
The iv3 vector refers to implied volatility data from day 3, the iv28 from day 28 and so on (this means we have a time axis of 7 days with day 3,day 28,...,day 398)
I need to do smooth spline interpolation for each pair (strikes,iv3) ,(strikes,iv28), ...,(strikes,iv398) I use csaps().
I works totally fine in 2d. Problem is I need to put all 2d plots in one 3d plot. But I do not need one surface over the whole observations in 3d, rather for each day and pair (strikes,iv28), (strikes,iv48), ....(strikes,iv398) one smoothing spline (so again 7 splines per pair and time -
spline1 one on (strikes,iv3, day3) , spline2 one on (strikes,iv28, day28) ,..., spline7 one on (strikes,iv398, day398)
I came so far to plot 3d the observation graph but without the splines, in 2d I used csaps() and fnplt() but this works not for 3d.
Please I appreciate any input
To the graphic below! Every dot line needs to get its spline that smooths the data. Splines are missing in the graphic!
Plot command was : plot3(repmat(3,length(strikes),1),strikes,iv3,'.') for each data tripel (days,strikes, iv)
and here the day3 data with yellow=spline(via csaps(strikes,iv3,0.001)) and blue=real observations
Kind Regards
GabrielGabriel Buchihahttps://jp.mathworks.com/matlabcentral/profile/authors/17561336-gabriel-buchihatag:jp.mathworks.com,2005:Question/5065902020-02-20T11:12:46Z2020-02-20T11:12:46ZStepper motor programming on arduino using drv8825 on MATLABI am facing a problem while programming a stepper motor on arduino using drv8825 on MATLAB. The results are not same while programming on these 2 platforms.
On Arduino IDE its working as expected using the following code:
# define dirpin 2
# define stepPin 3
# define stepsPerRevolution 200
void setup() {
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void loop() {
// Set the spinning direction clockwise:
digitalWrite(dirPin, HIGH);
// Spin the stepper motor 1 revolution slowly:
for (int i = 0; i < stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(600);
digitalWrite(stepPin, LOW);
delayMicroseconds(600);
}
delay(600);
// Set the spinning direction counterclockwise:
digitalWrite(dirPin, LOW);
//Spin the stepper motor 5 revolutions fast:
for (int i = 0; i < stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(600);
digitalWrite(stepPin, LOW);
delayMicroseconds(600);
}
delay(600);
}
On MATLAB I have tried to program the same but results are not same as shown on Arduino, using the following code:
clear a
% Arduino Declaration
a = arduino('COM4', 'Uno');
StepPerRevolution = 200;
% Pin Configuration
configurePin(a,'D2','DigitalOutput'); %D2 = Direction pin
configurePin(a,'D3','DigitalOutput'); %D3 = Step pin
while true
writeDigitalPin(a,'D2',1);
for i = 0:StepPerRevolution
writeDigitalPin(a,'D3',1);
pause(0.0006);
writeDigitalPin(a,'D3',0);
pause(0.0006);
end
writeDigitalPin(a,'D2',0);
for i = 0:StepPerRevolution
writeDigitalPin(a,'D3',1);
pause(0.0006);
writeDigitalPin(a,'D3',0);
pause(0.0006);
end
end
Please helpRajbir Singhhttps://jp.mathworks.com/matlabcentral/profile/authors/9632950-rajbir-singhtag:jp.mathworks.com,2005:Question/5065332020-02-20T04:34:48Z2020-02-20T11:08:59ZHow to obtain Velocity?I am trying to obtain velocity from a depth broad jump. I do have acceleration but I don't know why I cannot get velocity. How can I obtain velocity? Here is my code:
cd('C:\Users\cubes\OneDrive\Documents\pilot testing\Matt\Session 1\Force data')
z=xlsread('base_depth1.xlsx','Y9543:Y10562');
sf = 1000;
%low pass cut-off
cf = 50/(sf/2);
%b,a = filter coefficients
[b,a] = butter(4,cf);
%application of Filter
F_resultant_smoothed = filtfilt(b,a,abs(z));
%number of samples (cells) within the data
Nsamps = length(F_resultant_smoothed);
%T is Time, we use frequency and samples to obtain Time
t = (1/sf)*(1:Nsamps);
%Plot(x,y) for smoothed data or plot (x1,y1,x2,y2) for smoothed and non-smoothed data
plot(t,F_resultant_smoothed);
xlabel('Time(s)');
ylabel('vGRF(n)')
%gravity
g = 9.8;
%mass of the subject while standing
mass = F_resultant_smoothed (1)/g;
%acceleration from newtons second law
acceleration = (1/mass)*(F_resultant_smoothed-mass*g);Nicholas Cubilloshttps://jp.mathworks.com/matlabcentral/profile/authors/14714054-nicholas-cubillostag:jp.mathworks.com,2005:Question/5063592020-02-19T10:37:41Z2020-02-20T11:07:26ZNested parfor loops ( a statement within a parfor loop calls a function which also contains a parfor loop) Hi all
I need to use a parfor loop to speed up the code running. However, it reports errors when a statement within this parfor loop (marked in dFC.m, line 45) calls a function which also contains a parfor loop (marked in multilayerNetFunc.m, line 28). I can run them smoothly if I change either of them into 'for-loop'. I have been trying to find the solution by google and looking up the information in this community. But haven't found the right tips.
I really need these two parfor loops stay in position or it will be a week-long process for my computer.
Wish somebody could help me to figure out the solution!
Thanks!
ps: The two scripts have been attached to this post.
Yovan Hohttps://jp.mathworks.com/matlabcentral/profile/authors/15096397-yovan-hotag:jp.mathworks.com,2005:Question/5065882020-02-20T11:06:11Z2020-02-20T11:06:11Z improved Euler integration scheme (possible code error) in matlabI have this ex:
dx/dt = −x(1 − y), t0 = 0, x(t0) = 0.5, (3)
dy/dt = y(1 − x), t0 = 0, y(t0) = 2 (4)
These equations are also known as Lotka-Volterra or predator-prey equations modeling evolution of species as a function of time t. In the equations above variable x stands for the number of predators, and y is the number of prey.
Let [0, 40] be the interval of integration.
Please implement improved Euler integration scheme with ∆ = 0.001, ∆ = 0.002, and
∆ = 0.005 (2) for (3) and (4). Plot the values of x(t), y(t) for t ∈ [0, 40] in the xy plane.
I have written this so far but i get an error (line 32) about ''='' . I have also tried to write it as ''=='' but it still does not work
Could someone help me?
function [x_out,y_out,t_out]=improved_euler_CS(Delta_in,T0,T)
% setting up parameters of the integration
t_max=T;
t_min=T0;
Delta=Delta_in;
% defining initial conditions
t=t_min:Delta:t_max;
% reserving space for y
x=zeros(1,size(t,2));
y=zeros(1,size(t,2));
% defining initial conditions
z=zeros(1,2);
z(1)=0.5; % this is the initial condition for x
z(2)=2; % this is the initial condition for y
for i=1:size(t,2)
x(i)=z(1);
y(i)=z(2);
z1=competing_species_rhs(z);
z2=competing_species_rhs(z+Delta*z1);
z=z+Delta*(z1+z2)/2;
end;
% returning the values of x,y, and t back to MATLAB?s environment
t_out=t;
x_out=x;
y_out=y;
where the function competing species rhs is defined as
function z_out=competing_species_rhs(z)
%create a vector for storing the results;
p=zeros(1,2);
%z(1) is supposed to store the values of x
%z(2) is supposed to store the values of y
p(1) = (-z(1)*(1=(z(2))));
p(2) = z(2)*(1=(z(1)));
z_out=p;
end
endAnastasia Kyriakouhttps://jp.mathworks.com/matlabcentral/profile/authors/17300432-anastasia-kyriakoutag:jp.mathworks.com,2005:Question/5065872020-02-20T10:59:03Z2020-02-20T10:59:03ZImage read in MATLAB and CI have program to read an image in MATLAB
% open image file
fd = fopen("i00.dng");
% read order
order = fread(fd, 1, 'uint16');
I converted this to C as follows:
int order[1234];
FILE *fd=fopen("i00.dng","wb");
fread(order,2,1,fd);
printf("%d",order);
But the value of order in both cases is different. Did I convert it wrong?What is the exact replica of this code in C?Pravitha Ahttps://jp.mathworks.com/matlabcentral/profile/authors/11976906-pravitha-atag:jp.mathworks.com,2005:Question/5064922020-02-19T21:09:00Z2020-02-20T10:58:50ZHow do I plot animation of temperature data for a 3D object with time?I have generated a 4D matrix (x,y,z,t) which stores the temperature value for the corresponding x,y,z coordinates at 't' timestep. This is as a result of transient heat transfer analysis. Is there a way I can animate the plot for temperature in 3D?
If not, can I show the animation of temperature with time for any chosen z?Swapnil Sinhahttps://jp.mathworks.com/matlabcentral/profile/authors/11641260-swapnil-sinhatag:jp.mathworks.com,2005:Question/5065862020-02-20T10:57:23Z2020-02-20T10:58:31Zpca coeff,scores, explained for several matrices in a for loopHy everybody,
I have the following issue: i want to get the coeff, scores and explained values for all my 17 submatrices using the following loop.
How do i have to assign the variables coeff, score, explained in advance in the code that it gives me not 1 but 17 outputs?
for j=1:17 %number of my matrices
[coeff,score,~,~,explained] = pca(S.Submatrices.tp{1, j});
end
my matrices have the size (15,221).
Thanks for help!Kim Arnoldhttps://jp.mathworks.com/matlabcentral/profile/authors/15412980-kim-arnoldtag:jp.mathworks.com,2005:Question/5055542020-02-14T20:35:26Z2020-02-20T10:51:48ZGaussian Pulse to Drive Voltage sourceI need to develop a gaussian pulse to drive a voltage source for an FDTD simulation. The pulse is defined by the pulse half width t_w and the pulse delay t0.
the function is defined as: V_gauss(t) = e^ ( (t - t0)^2 / (t_w)^2 )
heres where im at:
t=-100:0.01:100;
t0=20;
t_w=2*pi*150/400; %% im assuming by "pulse half width" my professor is talking about center frequency?
Gpulse=exp((t - t0)^2 / (t_w)^2)
figure(2)
plot(t,Gpulse);
gpulse=fftshift(fft(Gpulse));
V_gauss=abs(gpulse);
figure(3)
plot(t,V_gauss,'-o');
xlim([-100 100])
i have also found the following code:
tc = gauspuls('cutoff',50e3,0.6,[],-40);
t1 = -tc : 1e-6 : tc;
y1 = gauspuls(t1,50e3,0.6);
t2 = linspace(-5,5);
y2 = sinc(t2);
subplot(2,1,1)
plot(t1*1e3,y1)
xlabel('Time (ms)')
ylabel('Amplitude')
title('Gaussian Pulse')
subplot(2,1,2)
plot(t2,y2)
xlabel('Time (sec)')
ylabel('Amplitude')
title('Sinc Function')
but dont know how to model it to what I need using the gauspuls function. Just posting this as well in case it helps.
I haven't actually learned about the intricacies of a gaussian pulse, it's simply a piece of a larger project and not the focus.
Lakerpurp24https://jp.mathworks.com/matlabcentral/profile/authors/14665319-lakerpurp24tag:jp.mathworks.com,2005:Question/5065852020-02-20T10:51:06Z2020-02-20T10:51:06ZAdd marker on selected Peaks of a plot with multiple curvesGood morning,
I'm having troubles in adding marker on selected peaks of a curve.
For instance, if i want to mark the peaks relative to (x2,y2) in the first part of the curve (until 150 kHz). How can i do?
Thanks in Advance
This is the part relative to the plot:
figure
semilogx (x2, y2,'DisplayName' , ' 25Hz ');
hold on
semilogx (x4, y4,'DisplayName' , ' 50Hz ');
semilogx (x6, y6,'DisplayName' , ' 100Hz ');
semilogx (x3, y3, 'DisplayName' , ' 25Hz ');
semilogx (x5, y5,'DisplayName' , ' 50Hz ');
semilogx (x7, y7,'DisplayName' , ' 100Hz ');
semilogx (xAV, yAV, 'DisplayName' , 'CISPR A (AV)')
semilogx (xQP, yQP, 'DisplayName' , 'CISPR A (QP)')
xlim([9000 30000000]);
title (' Variation of Output Frequency,S.C.,4kHz fs, phase R fix ' )
xlabel (' Frequency 9 kHz-30Mhz')
ylabel (' Voltage (dB\muV) ' )
legend
hold offmauro ucinihttps://jp.mathworks.com/matlabcentral/profile/authors/6160427-mauro-ucinitag:jp.mathworks.com,2005:Question/5059542020-02-17T14:42:32Z2020-02-20T10:46:27ZError using ezplot commandHi.
I´m trying to make a graph using the command "ezplot". But I get this error message: "Index exceeds the number of array elements (1)" and "error in ezplot>ezimplicit". Would you please help me to figure out what´s wrong?
This is my code:
clear all
syms x x(t) T x_0 xT
T=2;
x_0=0;
F(t)=int(x(t)-(diff(x(t))^2),t,0,T)
D=functionalDerivative(F,x)
x_sol1= dsolve(D,x(0)==x_0, x(T)==xT)
x_sol1(t)=subs(x_sol1);
figure(1);
ezplot(x_sol1(t),0,T);Adriana Castillo Castillohttps://jp.mathworks.com/matlabcentral/profile/authors/13495304-adriana-castillo-castillotag:jp.mathworks.com,2005:Question/5065312020-02-20T04:28:41Z2020-02-20T10:46:01ZNumerical simulation of population growthI am trying to numerically simulate the population growth model dn/dt=rn(n/u-1)(1-n/k) If u=1000 and k = 2000, plot solutions for 5 different values of N(0) < 3000. I know how to plot I am just not sure how I am supposed to go about numerically simulating the model.Clementine Furberhttps://jp.mathworks.com/matlabcentral/profile/authors/14549351-clementine-furbertag:jp.mathworks.com,2005:Question/5065842020-02-20T10:45:24Z2020-02-20T10:45:24ZHi. I'm trying to use the code below to get the modal assurance criterion. But I get an error saying that Index exceeds matrix dimensions. Thanks in advance
S1_mode_shape_1=2775;
S1_mode_shape_2=2794;
S1_mode_shape_3=3043;
S1_mode_shape_4=3179;
S1_mode_shape_5=3464;
S1_mode_shape_6=3901;
S1_mode_shape_7=4478;
S1_mode_shape_8=4756;
S1_mode_shape_9=4982;
S1_mode_shape_10=5664;
S1_mode_shape_11=6548;
S1_mode_shape_12=6680;
S1_mode_shape_13=6959;
S1_mode_shape_14=7032;
S1_mode_shape_15=7668;
S2_mode_shape_1=2720;
S2_mode_shape_2=2800;
S2_mode_shape_3=3040;
S2_mode_shape_4=3150;
S2_mode_shape_5=3500;
S2_mode_shape_6=3760;
S2_mode_shape_7=4400;
S2_mode_shape_8=4720;
S2_mode_shape_9=4900;
S2_mode_shape_10=5600;
S2_mode_shape_11=6480;
S2_mode_shape_12=6640;
S2_mode_shape_13=6980;
S2_mode_shape_14=7100;
S2_mode_shape_15=7400;
U1=S1_mode_shape_1; %Reference_mode_shape_1
U2=S1_mode_shape_2; %Reference_mode_shape_2
U3=S1_mode_shape_3; %Reference_mode_shape_3
U4=S1_mode_shape_4; %Reference_mode_shape_4
U5=S1_mode_shape_5; %Reference_mode_shape_5
U6=S1_mode_shape_6; %Reference_mode_shape_6
U7=S1_mode_shape_7; %Reference_mode_shape_8
U9=S1_mode_shape_9; %Reference_mode_shape_9
U10=S1_mode_shape_10; %Reference_mode_shape_10
U11=S1_mode_shape_11; %Reference_mode_shape_11
U12=S1_mode_shape_12; %Reference_mode_shape_12
U13=S1_mode_shape_13; %Reference_mode_shape_13
U14=S1_mode_shape_14; %Reference_mode_shape_14
U15=S1_mode_shape_15; %Reference_mode_shape_15
U1(:) %change matric of undamaged disk from 5x5 to 25x1
U2(:)
U3(:)
U4(:)
U5(:)
U6(:)
U7(:)
U8(:)
U9(:)
U10(:)
U11(:)
U12(:)
U13(:)
U14(:)
U15(:)
D1=S2_mode_shape_1; %Test_mode_shape_1
D2=S2_mode_shape_2; %Test_mode_shape_2
D3=S2_mode_shape_3; %Test_mode_shape_3
D4=S2_mode_shape_4; %Test_mode_shape_4
D5=S2_mode_shape_5; %Test_mode_shape_5
D6=S2_mode_shape_6; %Test_mode_shape_6
D7=S2_mode_shape_7; %Test_mode_shape_7
D8=S2_mode_shape_8; %Test_mode_shape_8
D9=S2_mode_shape_9; %Test_mode_shape_9
D10=S2_mode_shape_10; %Test_mode_shape_10
D11=S2_mode_shape_11; %Test_mode_shape_11
D12=S2_mode_shape_12; %Test_mode_shape_12
D13=S2_mode_shape_13; %Test_mode_shape_13
D14=S2_mode_shape_14; %Test_mode_shape_14
D15=S2_mode_shape_15; %Test_mode_shape_15
D1(:) %change matric of damaged disk from 5x5 to 25x1
D2(:)
D3(:)
D4(:)
D5(:)
D6(:)
D7(:)
D8(:)
D9(:)
D10(:)
D11(:)
D12(:)
D13(:)
D14(:)
D15(:)
U = zeros(25,15); %Create the main matric of undamaged disk
U(:,1) = U1(:);
U(:,2) = U2(:);
U(:,3) = U3(:);
U(:,4) = U4(:);
U(:,5) = U5(:);
U(:,6) = U6(:);
U(:,7) = U7(:);
U(:,8) = U8(:);
U(:,9) = U9(:);
U(:,10) = U10(:);
U(:,11) = U11(:);
U(:,12) = U12(:);
U(:,13) = U13(:);
U(:,14) = U14(:);
U(:,15) = U15(:);
U;
D = zeros(25,15); %Create the main matric of damaged disk
D(:,1) = D1(:);
D(:,2) = D2(:);
D(:,3) = D3(:);
D(:,4) = D4(:);
D(:,5) = D5(:);
D(:,6) = D6(:);
D(:,7) = D7(:);
D(:,8) = D8(:);
D(:,9) = D9(:);
D(:,10) = D10(:);
D(:,11) = D11(:);
D(:,12) = D12(:);
D(:,13) = D13(:);
D(:,14) = D14(:);
D(:,15) = D15(:);
D;
for u=1:15;
for k=1:15 ;
Qd25=D(:,u); % row of MAC are damaged mode
Qh25=U(:,k); % column of MAC are damaged mode
MAC(u,k)=((Qh25)'*Qd25*(Qh25)'*Qd25)/((Qh25)'*Qh25*(Qd25)'*Qd25);
end
end
M(i,j)=U(i,j).*D(i,j);
COMAC(i)=sum(Y)^2/( sum(U(i,j).^2)*sum(D(i,j).^2));
for i=1:25
j=1:15;
Y=abs(M(i,j));
sum(Y);
sum(U(i,j).^2);
sum(D(i,j).^2);
end
figure (1)
imagesc(MAC)
% title('MAC','FontSize', 16)
xlabel('Six mode shapes of intact case','FontSize', 16)
set(gca, 'XAxisLocation', 'top')
ylabel('Six mode shapes under 5kN','FontSize', 16)
colorbar; % set the colorbar
set(gca,'FontSize', 16); % fonts
grid on
figure (2)
bar(COMAC)
xlabel('Response point number','FontSize', 16)
set(gca, 'XAxisLocation', 'bottom')
ylabel('COMAC value at each response point','FontSize', 16)
axis([0 26 0 1])
set(gca,'FontSize', 16); % axies number fonts
grid on
kentridge mantshahttps://jp.mathworks.com/matlabcentral/profile/authors/17294452-kentridge-mantshatag:jp.mathworks.com,2005:Question/5065412020-02-20T05:30:13Z2020-02-20T10:43:45Zsolve a system of ODE equations and plotHi to everyone!
I have a system of four equations which are given in the following.
dA/dt=-k1*(exp(-E1/RT))*(A-(1/K)*B)
dB/dt=k1*(exp(-E1/RT))*(A-(1/K)*B)-k2*(exp(-E2/RT))*B
dM/dt=k2*(exp(-E2/RT))*B
C=-k2*(exp(-E2/RT))*B*r^2/(D*exp(M))-((k2*(exp(-E2/RT))*(E3-1))+k2*(exp(-E2/RT))*B*(r^2-R^2))/(((-D*exp(M))/r)+k2*(exp(-E2/RT)*(r/R))
T=700+5t
k1=1e5;
E1=100;
k2=1e6;
E2=90;
K=0.2*T+50;
D=10^(-6);
E3=1.5*T+0.5;
R=90;
R=8.314;
The initial conditions for [A,B,M,C]=[9,1,0,0] and the range of r is from 0 to 90.
I would like to solve these four equations in series and plot each variable vs. time. (A vs. time; B vs. time; C vs. time and M vs. time)
I was wondering if anyone can give me some suggestions. Thank you in advance!S Hhttps://jp.mathworks.com/matlabcentral/profile/authors/12117745-s-htag:jp.mathworks.com,2005:Question/5039322020-02-06T00:51:35Z2020-02-20T10:42:13ZWays of plotting a matrixHello, I am working on a simulation which diagonalizes a matrix for me, then I take the eigen vectors of said matrix and build a density of states. For computational purposes this is just an NxN matrix and each elements magnitude is the density of states at a specific location.
I am wondering if anyone has a good way to plot these values such that there is an interpolation between neighboring values and decent resolution. I am currently using pcolor and setting this to interpolate, but this does not seem to have the resolution I am after. Maybe there is a way to increase resolution and I am not aware of it?
Any ideas will be appreciated! Marcus Rosaleshttps://jp.mathworks.com/matlabcentral/profile/authors/7835065-marcus-rosalestag:jp.mathworks.com,2005:Question/5065832020-02-20T10:39:53Z2020-02-20T10:39:53Zmotherboard use for x86 target Which intel series of mother board can be used as x86 target.gaurav kanaujiahttps://jp.mathworks.com/matlabcentral/profile/authors/16104668-gaurav-kanaujiatag:jp.mathworks.com,2005:Question/5060102020-02-17T17:10:00Z2020-02-20T10:38:51ZI want to plot from -5 to 5 on the x and y, but I am having trouble. Any help?I want to plot from -5 to 5 on both the x andy
%mesh
X=-5:.5:5;
Y=-5:.5:5;
[x y]=meshgrid(X,Y);
% calculate
f=exp(-0.25.*sqrt(x.^2+y.^2));
%imagesc
figure(1)
imagesc(f);
colorbar
xlabel('x');
ylabel('y');
title('imagesc with colorbar')
%gradient
[fx,fy]=gradient(f);
figure(2)
quiver(fx,fy)
xlabel('fx');
ylabel('fy');
title('gradient plot')
Luis Hernandezhttps://jp.mathworks.com/matlabcentral/profile/authors/15785887-luis-hernandeztag:jp.mathworks.com,2005:Question/5065822020-02-20T10:31:44Z2020-02-20T10:31:44ZHow would I create a function to return a Look-up table containing the transfer function for increasing/decreasing the brightness of an image in a given amount?I am trying to create a function that returns a Look-up table containing the transfer function for increasing/decreasing brightness as follows;
if inputvalue < -c
outputvalue = 0
else if inputvalue > 255 - c
outputvalue = 255
else
outputvalue = inputvalue + c
Here is my attempt...
function Lut = brightnessLUT(c)
Lut = 1:256;
if c < 0
Lut = 0;
else if c > 255
Lut = 1:256;
else
Lut = 1:c;
end
Lut = uint8(Lut);
end
Would this be correct? When I use another function I to enhance an inputted image with the amount of c it doesn't seem to affect the brightness at all and the inputted image just stays the same. Any help would be great.
function Iout = enhanceBrightness(Iin,c)
Lut = brightnessLUT(c);
Iout = intlut(Iin,Lut);
endEJ_92https://jp.mathworks.com/matlabcentral/profile/authors/17589189-ej_92tag:jp.mathworks.com,2005:Question/5065812020-02-20T10:31:01Z2020-02-20T10:31:01ZHow to get this help file to runfunction [v,err,count] = MS1_Ideal_Gas(P)
% MS1_Ideal_Gas
% R = 0.082057; % Ideal gas constant in L atm / K mol
% T = 293; % Temperature in K
% P = [1 1.5 2 2.5 3 5 10 15 25 50 100];
% v = zeros(1,length(P));
% for i=1:length(P)
% [u,err,count] = MS1_Ideal_Gas(P(i));
% v(i)=u;
% end
% P1=[1:0.1:100];
% V1=R*T./P1;
% plot(P1,V1) %ideal
% hold on
% plot(P,v,'xr') %Redlich
% title('Molar Volume vs Pressure for Cl_2')
% xlabel('Pressure P (atm)')
% ylabel('Molar Volume v (L/mol)')
% legend({'Ideal Gas Law','Redlich-Kwong Equation'},'Location','northeast')
% Version 1: created 18/02/20. Author: Savana Stewart
% UCD ID: 19208141
% Inputs:
R = 0.082057; % Ideal gas constant in L atm / K mol
T = 293; % Temperature in K
Tc = 416.90; % Critical temperature of Cl_2 in K
Pc = 78.72918; % Critical Pressure of Cl_2 in atm
a = ((R^2)*(Tc^(5/2)))/(9*Pc*(2^(1/3)-1));
b = (R*Tc*(2^(1/3)-1))/(3*Pc);
% P Pressure in atm
% Outputs:
% v equals molar volume (V/n) in L/mol
% err equals modulus of function evaluated at approximate root.
% count is number of iterations taken by Newton-Raphson algorithm.
if (~isscalar(P)) || (~isreal(P)) || P <= 0
error('Input argument P must be positive real scalar.')
end
Iteration_limit = 20; % maximum number of iterations permitted
Tolerance = 10^7; % maximum acceptable value for modulus of
% function evaluated at estimated root3of
A = (a*P)/((R^2)*(T^(5/2)));
B = (b*P)/(R*T);
v = R * T / P; % Molar volume
Z = 1;
C = A-B-B^2; % Substitution to simplify equation
poly_f = [1 -1 C -A*B]; % = (Z^3) - (Z^2) + (A-B-(B^2))*Z - (A*B)
f = polyval(poly_f,Z);
poly_df = [0 3 -2 C]; % = 3*Z^2 - 2*Z + (A - B - (B^2))
for count = 1:Iteration_limit + 1
% Terminate with error message if iteration limit exceeded:
if count == Iteration_limit + 1
error('Iteration limit reached. Iteration did not converge.')
end
df = polyval(poly_df,Z);
Z = Z - (f/df); % Newton-Raphson iteration
% Terminate iteration if function is sufficiently small at current
% estimate
if abs(f) < Tolerance
break
end
end
v = Z*R*T/P; % Subsitiution to find v
% to find numerical values for table 2 in report:
%v1 = R * T / P;
%fprintf('P = %d \nv (Ideal Gas Law) = %d \nv (Redlich-Kwong) = %d \nrequires %d iterations \n \n',P,v1,v,count);
err = abs(f); % Error is magnitude of f(v) at final root estimate
help MS1_Ideal_Gas; % help function
end
When I type in the comments at the beginning if the file into the command window, it runs fine. However, When I tried to turn it into a help file the code no longer runs. How can I change the help file so it acts like I am just typing all of the first comments into the command window?Savana Stewarthttps://jp.mathworks.com/matlabcentral/profile/authors/13477751-savana-stewarttag:jp.mathworks.com,2005:Question/5064222020-02-19T15:15:30Z2020-02-20T10:30:18ZI want to identify left and right turns in the competition arena, is it possible to use image segmentation? I have tried in the image processing but, I don't think it will accept the three inputs of the cameraI want to identify left and right turns in the competition arena, is it possible to use image segmentation? I have tried in the image processing but, I don't think it will accept the three inputs of the camera.Keith Marangehttps://jp.mathworks.com/matlabcentral/profile/authors/16291687-keith-marangetag:jp.mathworks.com,2005:Question/5065802020-02-20T10:27:57Z2020-02-20T10:27:57Zhow to export output of MATLAB code to excel sheetI have 125 image files each of which contains 6 sub-images. The idea is to extract properties from the each sub-images of the image files. 5 properties are to be extracted from each sub-image 4 among which are extracted using GLCM. I need to store all the obtained feature matrix in excel format. So I need to get an excel sheet of 125*6*6 entries. Suggest me a possible modification in my code.
I = imread('2.jpg');
Im = rgb2gray(I);
K = imshow(Im);
I3 = imcrop();
imwrite(I3, 'out.png');
Ig = imread('out.png');
glcm = graycomatrix(Ig)
stats = graycoprops(glcm)
e = entropy(Ig)
closeAKHILA Lhttps://jp.mathworks.com/matlabcentral/profile/authors/17590033-akhila-ltag:jp.mathworks.com,2005:Question/5058232020-02-16T18:48:39Z2020-02-20T10:26:45ZFinite Difference Matrix HelpSo I have a finite difference problem with beam bending. I am trying define a matrix that follows the 4th order ODE for a Central Difference formula.
n= 10 %number of nodes in the beam
%% Step 2: Define the A Matrix
A = (((2*eye(N) +...
diag(ones(N-1,1),1)))+...
diag(ones(N-1,1),-1));
Now this generates a matrix of size N with '2' along the main diagonal. However, a 4th order ODE is different. So I guess my question is, is there a way to add in values '2' off the main diagonal? I've been trying to mess around with the code above, but it keeps saying the "matrix size dimensions must agree.
Justin Yeunghttps://jp.mathworks.com/matlabcentral/profile/authors/6834032-justin-yeungtag:jp.mathworks.com,2005:Question/5063182020-02-19T07:07:44Z2020-02-20T10:24:00Zhow can i find the distance from the peak of one wave to another wave in a image?i need to find the distance of the wave. i refer to some questions & answers from that i get to know can solve canny's edge detection method.
but i don't know how to process it. can anyone help me...?
basha Shaikhttps://jp.mathworks.com/matlabcentral/profile/authors/17371496-basha-shaiktag:jp.mathworks.com,2005:Question/5063902020-02-19T13:20:35Z2020-02-20T10:17:46ZPower fluctuating from battery. Voltage and current fluctuating.I am trying to compare the power in to my power out. However the voltage and current values are fluctuating from my Lithium Ion Battery that causes my power to fluctuate and I am not sure why. I would like to seek some help on this please.
EngTat Chunghttps://jp.mathworks.com/matlabcentral/profile/authors/14453027-engtat-chungtag:jp.mathworks.com,2005:Question/5065792020-02-20T05:00:00Z2020-02-20T10:16:03ZHow do I import links from IBM Rational DOORS as "in-link" rather than "out-link" in R2015b?When I link requirements from IBM Rational DOORS with Simulink in R2015b, the links are created as "out-link" only. I would like to import the links as "in-link". How can I create them as "in-link" rather than "out-link"?
MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-team