https://in.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-10-23T19:23:55Ztag:in.mathworks.com,2005:Question/4870682019-10-23T18:48:25Z2019-10-23T19:23:55ZI need help with my code using gaussian elimination.I keep getting NaN as my answer when I use gaussian elimination but according to f = A\b, there's only a couple of them that are NaN and the rest are actual answers. I would like to know how to fix my code to get it using the elimination method. This is my code:
% load
F1 = 10; %tons
F2 = 10;
F3 = 15;
F4 = 10;
F5 = 10;
c = cosd(45); % 45 degree angle
s = sind(45);
% coefficient matrix
A = [ 1 -c 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 -s 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 1 c -c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 s s 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 -c 0 0 0 0 1 -1 c 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 -s 0 0 0 -1 0 0 -s 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 c 0 0 0 0 0 0 -c 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;
0 s 0 0 0 -1 0 0 -s 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 1 0 0 0 -c 0 -1 c 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 s 0 0 s 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 c 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -s 0 1;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -c 0 0 0 -c 1 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -s 0 0 -1 c 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 -1 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0];
% load vector
b = [ 0
0
0
F1
0
F2
0
F3
0
0
0
0
0
0
0
F4
0
F5
0
0
0
0
0
0 ];
% solve linear system
% f = A\b
% plotTruss(f);
% function x = GuassNaive(A,b)
[m,n]=size(A);
if m~=n, error('Matrix A must be square'); end
nb = n+1;
Aug = [A,b];
for k = 1:n-1
% [big,i]=max(abs(Aug(k:n,k)));
% ipr=i+k-1;
% if ipr~=k
% Aug([k,ipr],:)=Aug([ipr,k],:);
% end
for i = k+1:n
factor = Aug(i,k)/Aug(k,k);
Aug(i,k:nb)=Aug(i,k:nb)-factor*Aug(k,k:nb);
end
end
x = zeros(n,1);
x(n)=Aug(n,nb)/Aug(n,n);
for i = n-1:-1:1
x(i)=(Aug(i,nb)-Aug(i,i+1:n)*x(i+1:n))/Aug(i,i);
end
% end
x
Susanhttps://in.mathworks.com/matlabcentral/profile/authors/16048830-susantag:in.mathworks.com,2005:Question/4788382019-09-04T09:16:54Z2019-10-23T19:22:51ZpredictorImportance for classification treesHello,
would the predictorImportance() function also work for classification trees (random forest, AdaBoostM1 or Bag method)?
I tested it already and it produces numbers, but are these as meaningful as for regression trees?
many thanks in advance.
StevenSteven Niggebruggehttps://in.mathworks.com/matlabcentral/profile/authors/5007241-steven-niggebruggetag:in.mathworks.com,2005:Question/4870662019-10-23T18:41:26Z2019-10-23T19:09:37ZHow to replace/delete some elements of a Matrix to a certain valueHello everyone,
I have a matrix of 2799x7 matrix and i want to delete 10% of the data points or individual cells randomly. Or replace 10% of the data sets to zero. The size of the matrix should remain the same after the operation.hasan haiderhttps://in.mathworks.com/matlabcentral/profile/authors/14699440-hasan-haidertag:in.mathworks.com,2005:Question/3061742016-10-07T06:31:21Z2019-10-23T19:03:44ZCan't get MWNumericArray out of c#I have this very simple test C# code that is supposed to get the number 24 into MATLAB
public MWNumericArray test()
{
int data = 24;
MWNumericArray array = data;
return array;
}
When I run test from MATLAB I get this error:
Error using mbm.sqlApache_Cassandra/test (line 24)
Message: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception.
Source: MWArray
HelpLink:
When I get the full errorcode from c# it looks like this:
{System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWArray' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. ---> System.Exception: Trouble initializing libraries required by .NET Assembly.
at MathWorks.MATLAB.NET.Utility.MWMCR..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWArray..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWNumericArray.get__Inf()
at MathWorks.MATLAB.NET.Arrays.MWNumericArray..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWNumericArray.op_Implicit(Int32 scalar)
at cassandra_sql.csql.test() in c:\Mercurial\MBM\c#\cassandra_sql\cassandra_sql\csql.cs:line 81}
Any idea what to do ?
Danhttps://in.mathworks.com/matlabcentral/profile/authors/1283916-dantag:in.mathworks.com,2005:Question/4870642019-10-23T18:32:14Z2019-10-23T19:02:21ZCould anyone help me to plot this integral function?f(t) =(0.217+0.259*exp(-t/172.9)+0.338*exp(-t/18.51)+0.186*exp(-t/1.186));
CF = vpaintegral(f,0,100);,Flavia Fanhttps://in.mathworks.com/matlabcentral/profile/authors/13742987-flavia-fantag:in.mathworks.com,2005:Question/4870672019-10-23T18:47:34Z2019-10-23T18:59:04ZHow to Merge lots of netcdf files into one comprehensive netcdf file?I have monthly NetCDF files from 1982-01-01 to 2015-12-01. I want to merge all these NetCDF files into one NetCDF file.
I would like to newly merge the NetCDF file have all data from very first month in 1982 till the end month of 2015.
How to do this? please help me.
All of my NetCDF files are the same ncdisp as below:
Format:
netcdf4_classic
Global Attributes:
Conventions = 'CF-1.0'
version = 'V1.0'
history = 'created 9/2016 by CAS NOAA/ESRL PSD'
title = 'CPC GLOBAL PRCP V1.0'
References = 'https://www.esrl.noaa.gov/psd/data/gridded/data.cpc.globalprecip.html'
dataset_title = 'CPC GLOBAL PRCP V1.0'
Source = 'ftp://ftp.cpc.ncep.noaa.gov/precip/CPC_UNI_PRCP/'
Dimensions:
lat = 360
lon = 720
time = 365 (UNLIMITED)
Variables:
lat
Size: 360x1
Dimensions: lat
Datatype: single
Attributes:
actual_range = [89.75 -89.75]
long_name = 'Latitude'
units = 'degrees_north'
axis = 'Y'
standard_name = 'latitude'
coordinate_defines = 'center'
lon
Size: 720x1
Dimensions: lon
Datatype: single
Attributes:
long_name = 'Longitude'
units = 'degrees_east'
axis = 'X'
standard_name = 'longitude'
actual_range = [0.25 359.75]
coordinate_defines = 'center'
time
Size: 365x1
Dimensions: time
Datatype: double
Attributes:
long_name = 'Time'
axis = 'T'
standard_name = 'time'
coordinate_defines = 'start'
actual_range = [718800 727536]
delta_t = '0000-00-01 00:00:00'
avg_period = '0000-00-01 00:00:00'
units = 'hours since 1900-01-01 00:00:00'
precip
Size: 720x360x365
Dimensions: lon,lat,time
Datatype: single
Attributes:
missing_value = -9.969209968386869e+36
var_desc = 'Precipitation'
level_desc = 'Surface'
statistic = 'Total'
parent_stat = 'Other'
long_name = 'Daily total of precipitation'
cell_methods = 'time: sum'
avg_period = '0000-00-01 00:00:00'
actual_range = [0 816.6611]
units = 'mm'
valid_range = [0 1000]
dataset = 'CPC Global Precipitation'
as I am totaly new to this topic if you can provide a sample code I would be so grateful.
thank you all
Behzad Navidihttps://in.mathworks.com/matlabcentral/profile/authors/15525777-behzad-naviditag:in.mathworks.com,2005:Question/4870702019-10-23T18:52:56Z2019-10-23T18:52:56ZHow to do frequency scaling in Frequency spectrum?disp('%=================================================%')
disp('%~~~~~~~~ `` Assalamualaikum `` ~~~~~~~~~%')
disp('% ```` Principle of Communication ( MATLAB ) ````%')
disp('')
disp('%`````````` *GROUP MEMBERS* ``````````%')
disp('%`` 1. ONG JIA EEK - A17MB0157 ``%')
disp('%`` 2. MAISARAAH YUZLAN - A17MB0078 ``%')
disp('%`` 3. NUR RAIHAN NAJAH BINTI TURIMAN - A17MB0137 ``%')
disp('')
disp('%=================================================%')
z=1
while z==1
A = menu('Please, select one! ','1.FULL AM','2.DSB-SC','3.SSB-SC','4.DSBSC & SSBSC SPECTRUM')
switch A
case 1
%>>>>>>>>>>>>>>>>>>>> 1.AM Modulation Simulation <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
close all;
%XXXXXXXXXXXXXXXXX modulating signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
disp('fc value must be larger than fm value.');
Em=input('Enter the value of amplitude modulation, Em ='); %amplitude of modulating signal
fm=input ('Enter the value of frequency modulation, fm ='); % Frequency of modulating signal
Tm=1/fm; % Time period of modulating signal
t=0:Tm/999:6*Tm; % Total time for modulated signal simulation (6 cycles will be displayed)
tm=0:Tm/999:6*Tm; % Total time for modulating signal simulation (6 cycles will be displayed)
ym=Em*cos(2*pi*fm*tm); % Equation of modulating signal
%XXXXXXXXXXXXXXXXXXXXX carrier signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
Ec=input('Enter the value of carrier signal amplitude, Ec =');% Amplitude of carrier signal
fc=input('Enter the value if carrier signal frequency, fc =');% Frequency of carrier signal
Tc=1/fc; % Time period of carrier signal
tc=0:Tc/999:6*Tc; % Total time for carrier signal simulation (6 cycles will be displayed)
yc=Ec*cos(2*pi*fc*tc);% Equation of carrier signal
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX AM Modulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
m=Em/Ec; % modulation index
y= Ec*(1+m*cos(2*pi*fm*t)).*cos(2*pi*fc*t); % Equation of Amplitude modulated signal
figure(1);
subplot(3,1,1);
plot(t,ym, 'g'), grid on;% Graphical representation of Modulating signal
title ( ' Modulating Signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');
subplot(3,1,2);
plot(t,yc, 'r'), grid on;% Graphical representation of carrier signal
title ( ' Carrier Signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');
subplot(3,1,3);
plot(t,y, 'm');% Graphical representation of AM signal
title ( ' Amplitude Modulated signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');
grid on;
case 2
%>>>>>>>>>>>>>>>>>>>> 2.Double-Sideband Suppressed-Carrier Transmission (DSB-SC) <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
clear all;
Em = input ('Enter the message signal amplitude = ');
Ec = input ('Enter the carrier signal amplitude = ');
fm = input ('Enter the message frequency = ');
fc = input ('Enter the carrier frequency = ');
m = Em/Ec;
%T=input('enter the duration over which the signal is to be plotted= ')
%fs=input('enter the sampling frequency= ')
%t=0:T/fs:T;
% Representation of the Message Signal
t = 0:0.0001:0.05;
Message_Signal = Em*cos (2*pi*fm*t);
subplot (3,1,1);
plot (t,Message_Signal,'b');
xlabel ('Time');
ylabel ('Amplitude');
title ('Message Signal');
legend ('Message Signal');
% Representation of the Carrier Signal
Carrier_Signal = cos(2*pi*fc*t);
subplot (3,1,2);
plot (t,Carrier_Signal,'r');
xlabel ('Time');
ylabel ('Amplitude');
title ('Carrier Signal');
legend ('Carrier Signal');
% Representation of the DSBSC Signal
DSBSC_Signal=Ec*m.*cos (2*pi*fm*t).*cos (2*pi*fc*t)
subplot (3,1,3);
plot (t,DSBSC_Signal,'m');
xlabel ('Time');
ylabel ('Amplitude');
title ('Double Sideband Suppressed Carrier Wave');
legend ('DSB-SC Signal');
% Add title to the Overall Plot
ha = axes ('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'off');
text (0.5, 1,'\bf Analog Modulation Technique: Double Sideband Suppressed-Carrier Transmission (DSB-SC)','HorizontalAlignment','center','VerticalAlignment', 'top')
case 3
%>>>>>>>>>>>>>>>>>>>> 3.Single-Sideband Suppressed-Carrier Transmission (SSB-SC) <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
clear all;
close all;
fm=input('enter the message frequency fm = ')
fc=input('enter the carrier frequency fc = ')
T=input('enter the duration over which the signal is to be plotted = ')
fs=input('enter the sampling frequency = ')
t=0:T/fs:T;
%t = 0:0.0001:0.05;
%generation of Modulating and Carrier signals and their Hilbert Transforms
m=cos(2*pi*fm*t) %modulating signal
m1=cos(2*pi*fm*t-(pi/2)) %Hilbert signal
n=cos(2*pi*fc*t) %carrier signal
n1=cos(2*pi*fc*t-(pi/2)) %Hilbert signal
%%generation of Two AM-DSB-SC signals
M=m.*n;
M1=m1.*n1;
%%generation of AM-SSB-SC signal
ssb=M+M1; %modulated signal
subplot (3,1,1);
plot (t,m,'b');
xlabel ('Time');
ylabel ('Amplitude');
title ('Message Signal');
subplot (3,1,2);
plot (t,n,'r');
xlabel ('Time');
ylabel ('Amplitude');
title ('Carrier Signal');
subplot (3,1,3);
plot (t,ssb,'m');
xlabel ('Time');
ylabel ('Amplitude');
title ('Single Sideband Suppressed Carrier Wave');
ha = axes ('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'off');
text (0.5, 1,'\bf Analog Modulation Technique: Single Sideband Suppressed-Carrier Transmission (SSB-SC)','HorizontalAlignment','center','VerticalAlignment', 'top')
case 4
%>>>>>>>>>>>>>>>>>>>> 4.DSBSC AND SSBSC FREQUENCY SPECTRUM <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
close all;
%XXXXXXXXXXXXXXXXX modulating signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
disp('fc value must be larger than fm value.');
Em=input('Enter the value of amplitude modulation, Em ='); %amplitude of modulating signal
fm=input ('Enter the value of frequency modulation, fm ='); % Frequency of modulating signal
Tm=1/fm; % Time period of modulating signal
t=0:Tm/999:6*Tm; % Total time for modulated signal simulation (6 cycles will be displayed)
tm=0:Tm/999:6*Tm; % Total time for modulating signal simulation (6 cycles will be displayed)
ym=Em*cos(2*pi*fm*tm); % Equation of modulating signal
%XXXXXXXXXXXXXXXXXXXXX carrier signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
Ec=input('Enter the value of carrier signal amplitude, Ec =');% Amplitude of carrier signal
fc=input('Enter the value if carrier signal frequency, fc =');% Frequency of carrier signal
Tc=1/fc; % Time period of carrier signal
tc=0:Tc/999:6*Tc; % Total time for carrier signal simulation (6 cycles will be displayed)
yc=Ec*cos(2*pi*fc*tc);% Equation of carrier signal
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX AM Modulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
m=Em/Ec; % modulation index
y= Ec*(1+m*cos(2*pi*fm*t)).*cos(2*pi*fc*t); % Equation of Amplitude modulated signal
%XXXXXXXXXXXXXXXXXXXXXXX Frequency Spectrum Of Modulated Signal XXXXXXXXXXX
N = length(y); %Number of samples
fs= 2*fc; % Sample frequency (Hz)
f =(0:N-1)*(fs/N); %frequency range(Hz)
% Double-sided amplitude spectrum
figure(2);
subplot(3,1,1);
Amp = abs(fftshift(fft(y))); %Amplitude of spectrum
plot(f, Amp, 'g')
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Double-sideband frequency spectrum (Hertz)');
% Single-sided amplitude spectrum with frequency axis in Hertz
subplot(3,1,2);
Amp = abs(fft(y)); %Amplitude of modulated signal in Frequency spectrum
plot(f, Amp,'b');
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Single-sideband frequency spectrum (Hertz)');
%>>>>>>>>>>>>>>>>>>>>>> end of program <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
end
B = menu('Do you want to continue?','1.Yes','2.No');
switch B
case 1
z=1;
case 2
z=0;
end
end
As above is my code, I wish to obtain the correct frequency spectrum code for ssb and dsb but unfortunately, I couldn't get it.ong jia eekhttps://in.mathworks.com/matlabcentral/profile/authors/16402278-ong-jia-eektag:in.mathworks.com,2005:Question/4870442019-10-23T16:58:21Z2019-10-23T18:52:35ZZ- score of a multidimensional arrayHi I am new to matlab. I have a data set on a grid at 0.5 with x 141 y, 71 and x38. I am trying to get z scores for this multidimensional array. I used the code z=zscore(x) to get the z-scores which I got on the shape of 1*71*38. I want to end with a z-score per year instead of 2,698 values. Is there anyway I can get this?
Thanks in advance for your help.Emmanuel Gonzalez-Figueroahttps://in.mathworks.com/matlabcentral/profile/authors/15423469-emmanuel-gonzalez-figueroatag:in.mathworks.com,2005:Question/4870692019-10-23T18:52:17Z2019-10-23T18:52:17ZEdge weight determining using nodes.
I need to find the edge weight using the equation Sij =Hij/Hi , Hi represents the earthquake number occurring in node i, Hij indicates the earthquake number of node j affected by node i.How I find the Hi and Hj.
http://service.scedc.caltech.edu/ftp/catalogs/SCEC_DC/ I take the dataset from this and I attached a .txt format here.I try to do with txt file.Silpa Khttps://in.mathworks.com/matlabcentral/profile/authors/15760628-silpa-ktag:in.mathworks.com,2005:Question/3368182017-04-23T16:25:37Z2019-10-23T18:44:39ZLivescript editor is always loading<</matlabcentral/answers/uploaded_files/75916/Untitled.jpg>>
After I open a new livescript, the loading bar in the middle of editor never disappears.
Also 'Open' 'Save' 'Print' buttons stays Gray. When I close the script matlab asks me if I want to save changes before exit (this is the only way to save the .mlx file).
I can compile live scripts.
I don't have any problem with regular script files.Arin Altuntashttps://in.mathworks.com/matlabcentral/profile/authors/9462167-arin-altuntastag:in.mathworks.com,2005:Question/4870652019-10-23T18:39:21Z2019-10-23T18:43:22ZProblems with graphics card So just installed MATLAB with my students license on linux mint 18.3.
And when i boot up the program i get this output on matlab's console.
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x6c0490a8, isOwner false, <3ccc34ab, 372227ee>[count 0, qsz 0, owner <NULL>]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
Exception in thread "Startup Class Loader": java.lang.InternalError: XXX0 profile[1]: GL3bc -> profileImpl GL4bc !!! not mapped
at com.jogamp.opengl.GLProfile.computeProfileMap(GLProfile.java:2047)
at com.jogamp.opengl.GLProfile.initProfilesForDeviceCritical(GLProfile.java:1917)
at com.jogamp.opengl.GLProfile.initProfilesForDevice(GLProfile.java:1866)
at com.jogamp.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1835)
at com.jogamp.opengl.GLProfile.access$000(GLProfile.java:79)
at com.jogamp.opengl.GLProfile$1.run(GLProfile.java:229)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:215)
at com.mathworks.hg.peer.JOGLInitializer.initializeJOGL(JOGLInitializer.java:47)
at com.mathworks.hg.peer.JOGLInitializer.<clinit>(JOGLInitializer.java:25)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:258)
at com.mathworks.mde.desk.StartupClassLoader.access$1000(StartupClassLoader.java:25)
at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:245)
at java.lang.Thread.run(Thread.java:748)
So i can infer its having issues with my graphics card, my drivers are up to date so i don't really know what may be the source of the problem.
Code seems to be working just fine, but plotting gives no outcome and another error.
My graphics card is an integrated AMD APU.
AMD A6-7310 APU with AMD Radeon R4
I've also ran matlab on a windows partition on the same computer and i had no issues there.José Luis Martín Robleshttps://in.mathworks.com/matlabcentral/profile/authors/16621522-jose-luis-martin-roblestag:in.mathworks.com,2005:Question/4870422019-10-23T16:28:14Z2019-10-23T18:38:53ZHow can select apecific rows from text files Hi , i have theses data sets as text file,
i need extract and save specific rows only ( i need the rows that contains the words : ReadReq or WriteReq , ( otherwise negleget all other rwos !)
example: i need extrect the rows contain on the words inside its ( readReq or Writereq) such as :
3411151194500: system.cpu04.icache: ReadReq [380730:380733] IF hit state: 7 (E) valid: 1 writable: 1 readable: 1 dirty: 0 tag: 1c0
3411151194500: system.cpu04.dcache: WriteReq [a22a48:a22a4f] miss
from the original text file :
3411151194500: system.cpu04.icache: ReadReq [380730:380733] IF hit state: 7 (E) valid: 1 writable: 1 readable: 1 dirty: 0 tag: 1c0
3411151194500: system.cpu04.dcache: createMissPacket: created ReadExReq [a22a40:a22a7f] from WriteReq [a22a48:a22a4f]
3411151194500: system.cpu04.dcache: WriteReq [a22a48:a22a4f] miss
3411151194500: system.cpu04.dcache: recvAtomic: Sending an atomic ReadExReq [a22a40:a22a7f]
3411151194500: system.cpu04.dcache: Block addr 0xa22a40 (ns) moving from state 0 to state: 7 (E) valid: 1 writable: 1 readable: 1 dirty: 0 tag: 511
I appriciate for any hepl please
Furat Alobaidyhttps://in.mathworks.com/matlabcentral/profile/authors/6214076-furat-alobaidytag:in.mathworks.com,2005:Question/4860492019-10-18T05:58:46Z2019-10-23T18:36:19Zconcat images in orderhello guys
i have 10 images of size 512x512
i need to concat 3 images at first for example
i want to concat 1st image and 2nd image and 3rd image in one image (like RGB form)
then i want to concat 2nd image and 3rd image and 4th image in one image to make the second image
then i want to concat 3rd image and 4th image and 5th image in one image to make the third image and so on
so the total number of images that should be obtained 8 images
can you please help me on that
thankskhaled alsaihhttps://in.mathworks.com/matlabcentral/profile/authors/11188696-khaled-alsaihtag:in.mathworks.com,2005:Question/654022013-02-28T21:16:48Z2019-10-23T18:35:44Zhow to set graph size how to set my graphic size to (w:h=550:400) now my graph size is 560:420 (automatic)
[ day_number, daily_rain ] = DailyRain( RainData, 2010, 1);
andemande = plot( day_number, daily_rain,'-ok' );
set(andemande,'LineWidth',1);
day_numbermax = max(day_number);
day_numbermin = min(day_number);
datetick('x','dd-mmm','keepticks')
grid on;
ylabel('Akumulasi Curah Hujan (mm)')
xlabel('Hari')
xlim([day_numbermin day_numbermax])Soni huuhttps://in.mathworks.com/matlabcentral/profile/authors/3546904-soni-huutag:in.mathworks.com,2005:Question/4869582019-10-23T08:32:12Z2019-10-23T18:31:32ZODE coupled with classic equationHi everybody.
After some research can't found a solution..
I have 2 variable wich depend on time : E and W(E)
then I have an differential equation of rho inked to W so linked to E so linked to t.
Can I use E et W as vector inside the ODE declaration?
clc
clear all
close all
u=2.405;
c=3e8;
T0=100e-15;
lambda0=515e-9;
w0=2.*pi.*c./lambda0;
Ej=100e-6;
Pp=Ej./T0;
r=18e-6;
th=250e-9;
s=0.085;
dt=T0./1000;
t=-T0*5:dt:T0*5;
Fs=1./dt;
nn=length(t),
freq = Fs*linspace(0,(nn/2),(nn/2)+2)/nn+c/lambda0;
freq=fliplr(freq(1:end-1));
l=c./freq;
ll=-fliplr(l);
lll=ll-ll(1)+l(end);
lll = (circshift(lll',-1))';
lambda=[l lll];
lambda=lambda(1:end-1);
w=2.*pi.*c./lambda;
E=Pp.*exp(-(t./T0).^2).*cos(w0.*t);
% plot(t,E)
a=r.*( 1+ s.*(2*pi.*c).^2./ (w.*w.*r.*th) ).^(-1);
% plot(lambda,a)
a=9.9992e28;
b=3.5482e11;
rho0=2.7e26;
W=a./(abs(E)).*exp(-b./(abs(E)));
syms rho(t) EE(t) WW(t)% Y ;
ode1= EE== Pp.*exp(-(t./T0).^2).*cos(w0.*t);
ode2 = WW==a./(abs(EE)).*exp(-b./(abs(EE)))
ode3 = diff(rho,t) == W(t) .*(rho0 - rho);
ode=[ode1 ode2] ode3
rhoSol=solve(ode)
%%%or
yms rho(t) ;
ode = diff(rho,t) == W(t) .*(rho0-rho);
rhoSol=solve(ode)
If you have an idea to solve this?
Regards
MMMartinMhttps://in.mathworks.com/matlabcentral/profile/authors/4816064-martinmtag:in.mathworks.com,2005:Question/4870632019-10-23T18:29:42Z2019-10-23T18:29:42ZFinding transmission map of an image.How to calculate transmission map of an image using standard deviation.
I used the following equation but I didn't get the correct output.
A is airlight.Silpa Khttps://in.mathworks.com/matlabcentral/profile/authors/15760628-silpa-ktag:in.mathworks.com,2005:Question/4870622019-10-23T18:28:47Z2019-10-23T18:28:47ZEV simulation- Battery Capacity LossI am currently researching the following for part of my dissertation where i would be doing a predictive 1D model on the Capacity or Battery Capacity Loss Due To Bi-Directional Energy Exchange in a vehicle to grid (V2G) system.
I wanted to know I could receive any feedback on how I could go about modelling this with some assumptions and parameters. This would include an interface where you can choose variables and from that a predictive result would be generated.
Please feel free to comment.Mayowa Sanusihttps://in.mathworks.com/matlabcentral/profile/authors/13314542-mayowa-sanusitag:in.mathworks.com,2005:Question/4870592019-10-23T18:05:10Z2019-10-23T18:26:28ZA switch case statement that will help me to either run codeS in Windows or linux, based on whichever OS it isI want to write a switch case statement that will help me to either run my code in Windows or linux, based on whichever OS it is. Any Suggestions!Sansit Dashttps://in.mathworks.com/matlabcentral/profile/authors/13525519-sansit-dastag:in.mathworks.com,2005:Question/4870612019-10-23T18:21:28Z2019-10-23T18:24:14ZHow to change the size of a plot figureHello,
I have a question. I would like to remake the size of my plots in matlab. Especially, i have observed that the plots have a "rectangle" format. So I would like to make my plot in a "square" format. I mean that I want my X axes to have the same size with the Y axis.
Could you please help me ?Ravnalis Michaelhttps://in.mathworks.com/matlabcentral/profile/authors/15708342-ravnalis-michaeltag:in.mathworks.com,2005:Question/4870602019-10-23T18:19:46Z2019-10-23T18:19:46Zhow to make a for loop into a tableHi, ı want to make table but ı dont know how can ı do. Here, z is 2x1 matrix and I want to array all z values side by side,any advise?
q=1:9
for j=0:length(q)
i=(2*j)+1;
z=d(:,j+1)*b(:,i:i+1)*c(:,j+1)
endOnur Kurthttps://in.mathworks.com/matlabcentral/profile/authors/13664474-onur-kurttag:in.mathworks.com,2005:Question/4869042019-10-23T00:34:45Z2019-10-23T18:09:21ZDetecting which mouse button is pressed in a UIFigureWindowButtonDown callbackIn App Designer, how how can I detect which mouse button (Left, Right, Middle) was pressed in a UIFigureWindowButtonDownUIFigureWindowButtonDown callback?Andrei Veldmanhttps://in.mathworks.com/matlabcentral/profile/authors/256651-andrei-veldmantag:in.mathworks.com,2005:Question/4868102019-10-22T14:55:18Z2019-10-23T18:07:38ZRSVP : REPLACE LETTERS WITH DIGITS% CONDITION 1 = RSVP OF 13-21 LETTERS RANDOMLY WITHOUT REPLACEMENT
% CONDITION 2 = 2 OF THE LETTERS WERE REPLACED WITH DIGITS, RANDOMLY DRAWN
% CONDITION 3 = T2 IS PRESENTED 3 TO 6 TEMPORAL POSITIONS FROM THE END
% CONDITION 4 = T1 AND T2 VARIED FROM 1:5 ITEMS
I am trying to run psychtoolbox for my RSVP experiment. can someone please help me to program (replace) letter stream with T2 and T1 as required in condition 3 and condition 4.
s = ['A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'J' 'K' 'L' 'M' 'N' 'P' 'R' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'];
str=datasample(s,1,'Replace', false);
nletters = [13:21];
ntrial = datasample(nletters,1);
T1 = randi([2,9], black);
T2 = randi([2,9], black);
l2 = datasample(nletter);
for index = 1:ntrial
str=datasample(s,1,'Replace', false)
T1 = strrep(s,
T2 = strrep(s,
endMigmar Tseringhttps://in.mathworks.com/matlabcentral/profile/authors/16106396-migmar-tseringtag:in.mathworks.com,2005:Question/4870152019-10-23T13:47:30Z2019-10-23T18:03:36ZIs this a Matlab bug? The use of Ctrl + A to select allI use Ctrl + A and then right click "smart indent" a lot.
Unfortunately, every time I do that, my cursor is moved to the very end of my script. This is very annoying, because I have tens of thousands of lines. Is there an easy way to make sure that when I apply Ctrl + A, my cursor will stay at my current location?
Leonhttps://in.mathworks.com/matlabcentral/profile/authors/3133287-leontag:in.mathworks.com,2005:Question/4870582019-10-23T18:01:15Z2019-10-23T18:01:15ZAdding OccupancyMap to GUIHello everyone,
I would like to know if there is any way to add an OccupancyMap to a Gui object such as axes?
I know how to add polarplot to a polaraxes object:
plot_object= polaraxes('Units','pixels','Position',[50,200,400,400]);
polarplot(plot_object,obrot_radians,distance,'.');
and i want to do it with an occupancyMap
map = occupancyMap(6,6,50);
map_object= axes('Units','pixels','Position',[550,200,400,400]);
Is there any way or should I try this different way?
If you need more code or information just tell.
Jan Gontarekhttps://in.mathworks.com/matlabcentral/profile/authors/9687958-jan-gontarektag:in.mathworks.com,2005:Question/4870572019-10-23T18:00:27Z2019-10-23T18:00:27ZCurve fitting advises ?Hello !
Context
I have to perform two curve fitting on experimental data, one after the other.
To clarify this, I have a data set witch I fit to obtain a function .
Next I integrate this function to obtain and finally fit the data to obtain .
So I now have a "main" variable witch allows me to compute and then .
Problem
Due to the two fitting one after the other, I have to perform very accurate fittings.
Olso, the fitting have to support a bit of extrapolation (I don't care much of the value as long at it doesn't explode immediately out of bounds), so I would avoid polynomial functions as much as possible ...
Here what I mannaged to do so far with and
The fittings function look like :
and
As you can see, the fitting function voluntuarly force .
I chose these function looking around but I'm clearly not an expert, any ideas on a way to improve it ?
You will find the RAW data and my results attached.
Thanks !
florian Shttps://in.mathworks.com/matlabcentral/profile/authors/11137481-florian-stag:in.mathworks.com,2005:Question/4870562019-10-23T17:59:17Z2019-10-23T17:59:17ZAccessing 'Modify Duty Cycle of ePWM Using DMA' built in example.Hi everyone,
I am using MATLAB 2017a for code generation for C2000 controllers and wanted to implement ePWM. Having searched web for ePWM, I found few examples on MATLAB website which can be opened by entering a command in command window like:
c28035pfc.slx
DCDC_Buck_Sim.mdl
c28x7x_c28004x_dma_epwm
So when I type these commands in window, it returns me the error: No system or file called 'xyz' found.
Can someone help me?
RegardsMustafeez ul Hassanhttps://in.mathworks.com/matlabcentral/profile/authors/16152124-mustafeez-ul-hassantag:in.mathworks.com,2005:Question/4870552019-10-23T17:57:24Z2019-10-23T17:57:24ZHow to speed up quantilepredict?Treebagger leverages the parallel toolbox natively while quantilepredict does not.
I put quantilepredict within a parfor and split the predictions into n nodes.
That works nicely but would like to see if there are other additional methods to speed up quantilepredict?MEGChttps://in.mathworks.com/matlabcentral/profile/authors/12756054-megctag:in.mathworks.com,2005:Question/4870462019-10-23T17:14:59Z2019-10-23T17:53:48ZClipping sin wave script, what is not correct ? Write a script to generate the signal values for the figure above corresponding to equally-spaced time values ranging from 0 to 6*pi . Assign these time values to the variable Time. Assign the resulting voltage values to the variable signalVoltage. The sinusoidal function is given by the formula: Y=7sin(x) In order to model the clipping at plus or minus 5 Volts, you will need to replace any values of y that are greater than the threshold of 5 with the value 5. Similarly you will need to replace any values of y that are less than with the value -5
My attempt:
Time= 0:6*pi
Signal voltage = 7sin(time)
Plot ( time, signal voltage)
Signalvoltagelim([-5,5])
Don’t know what I am doing wrong. What in my script is wrong ? Estela Barrios Lopezhttps://in.mathworks.com/matlabcentral/profile/authors/16046760-estela-barrios-lopeztag:in.mathworks.com,2005:Question/4870502019-10-23T17:27:31Z2019-10-23T17:46:42ZHow to plot like the inserted picture?Hello guys,
I want to plot like the picture below in matlab:
Is it possible in Matlab?
In X-Axis is the Frequency.
Every row is a node and the colours are the values of the results.
Ajhttps://in.mathworks.com/matlabcentral/profile/authors/8048998-ajtag:in.mathworks.com,2005:Question/4864702019-10-20T22:58:31Z2019-10-23T17:43:17ZReading different images in a folder when they have similar extensionsHi,
Let's say I have 6 images in a folder. Three images are named SOU_123_001.tif , SOU_123_002.tif, SOU_123_003.tif, S and the other three images are labelled SOU_123_001_bin.tif, SOU_123_002_bin.tif, SOU_123_003_bin.tif. So the difference between the two sets of images files is the bin in the file name, I am able to use bin to specify only the bin images... code below
image_folder_binary = 'SAME_PATH_WITH_BOTH_FILE_TYPES';
filenames_bin = dir(fullfile(image_folder_binary, '*bin.tif')); % read all images with a sppecified extention, its tif in our case
binary_images = numel(filenames_bin);
I am not sure how to specify the non bin tif images.
Any help?no zoophttps://in.mathworks.com/matlabcentral/profile/authors/15501100-no-zooptag:in.mathworks.com,2005:Question/4870542019-10-23T17:42:54Z2019-10-23T17:42:54ZProblem with the TreeBagger CommandHi,
I am using the TreeBagger command to produce the random forest regression model. My syntax is like the following:
Mdl=TreeBagger(1000,Training_Input,Training_Output,'Method','regression')
My Training_Input data is a matrix of 6768X400 and my Training_Output is a matrix of 6768X998
But while trying to execute I am getting the following error:
Error using classreg.learning.regr.FullRegressionModel.prepareData (line 245)
Invalid data type. Response must be a double or single vector.
Error in TreeBagger/init (line 1346)
classreg.learning.regr.FullRegressionModel.prepareData(...
Error in TreeBagger (line 616)
bagger = init(bagger,X,Y,makeArgs{:});
Error in Neural_network_OPF (line 71)
Mdl=TreeBagger(1000,Training_Input,double(Training_Output),'Method','regression');
I have checked the line inside the FullRegressionModel.m where the error is stemming from, it resulted from a check whether my response variable is vector or float.
I am really confused why this error is popping up. Can anyone help me fix it?
Regards,
JubeyerJubeyer Rahmanhttps://in.mathworks.com/matlabcentral/profile/authors/8384926-jubeyer-rahmantag:in.mathworks.com,2005:Question/4870532019-10-23T17:42:20Z2019-10-23T17:42:20ZHow to show a figure automatically when it is docked?Hi everyone,
I set my code for automatically dock my figures, but when the figures are generated, the user interface still shows the editor but no the generated figure.
Does anybody know how to display the docked figure automatically when it is generated?Juan Pablo Angelhttps://in.mathworks.com/matlabcentral/profile/authors/2595980-juan-pablo-angeltag:in.mathworks.com,2005:Question/3762222018-01-09T05:34:08Z2019-10-23T17:42:11ZHow to declare a point at a particular coordinate in matlab?Example: sink=50 plots the point sink at (0,50) on the y-axis. How to declare the variable if it were located at (50,0) or (50,50)?? sink=(0,50) gives error and sink=[0,50] plots point at x=0 and x=50 which is wrong.Shailaja Prabakarhttps://in.mathworks.com/matlabcentral/profile/authors/8476361-shailaja-prabakartag:in.mathworks.com,2005:Question/4870522019-10-23T17:38:12Z2019-10-23T17:38:12Zhow i can use a model (net.mat) from Fitting Neural Network in App DesignerHi. i have a model (net.mat) fot predict de load electricity demand, from Neural Net Fitting. For get the result in space of matlab, i use these code: y_predict= sim(net,Xp_net')'. (Xp_net is the predictors for get the forecast).
Now, i whant to create a App Designer for use that model, but i don´t know how call the model into the app Designer.
From some information about it, i have :
in App Designer, i created a Private Property(net):
properties (Access = private)
net;
Y_predict;
end
for charge the model i used this code in startupFcn(app):
function startupFcn(app)
app.net.net = load("C:\Predictor Demanda S.N.I\App\net.mat"); %para predicción del día siguiente
app.net = app.net.net; %net pronostico dia siguiente
end
to excecute the model, into the callback i have:
[Y_predict] = sim(app.net, app.Xp_prediccion)
in that part, i have a problem, because de code is not not recognized.
how I can get Y_predict?. The idea is that the model is in a folder (C:\Predictor Demanda S.N.I\App), and is called by the app dessigner.
thanks for you help.
Juanc. Pozuelos
Guatemala
Juan Carlos Pozuelos Buezohttps://in.mathworks.com/matlabcentral/profile/authors/9694902-juan-carlos-pozuelos-buezotag:in.mathworks.com,2005:Question/4870512019-10-23T17:28:04Z2019-10-23T17:38:01ZReplacing elements in a vectorI have a row vector which has 400 elements. All the elements are whole numbers and fluctuate between 60-70. I want to replace the elements with numbers between 1-11. As in all elements=60 should be replaced with 1, all elements=61 should be replaced with 2.....all elements=70 should be replaced with 11 and so on and so forth.
Can someone suggest a way to do this?
Thank you.
Ahmed.ARhttps://in.mathworks.com/matlabcentral/profile/authors/12872083-artag:in.mathworks.com,2005:Question/4867842019-10-22T13:32:18Z2019-10-23T17:35:58ZDice rolling & loopsHi! Im currently solving a task in which i have to simulate dice rolling. I'm supposed to generate 10 random numbers (between 1 and 6 of course, that part I've managed to do using a=rand(1,10) and then multiplying with 6 and rounding them). The next part is writing a loop which I'm struggling with. If 5 or 6 is gotten 7 or more times its supposed to display 'gain is 2',if 5 or 6 is gotten 4,5 or 6 times then display gain is 1 and if its gotten 4 or less times then gain is 0.
Any help or advice is appreciated Nina Helenahttps://in.mathworks.com/matlabcentral/profile/authors/16647397-nina-helenatag:in.mathworks.com,2005:Question/4870482019-10-23T17:17:52Z2019-10-23T17:35:57ZI was looking for the code for the sample appdMemoryMonitorExample and could not find itwhere do I locate the code for appdMemoryMonitorExamplemindy matusewiczhttps://in.mathworks.com/matlabcentral/profile/authors/16659847-mindy-matusewicztag:in.mathworks.com,2005:Question/4405312019-01-19T18:11:30Z2019-10-23T17:27:19ZSSH Key for GitHub not working (MacOS)I've done what's stated in this post to enable GitHub auth without having to enter username and password over and over https://www.mathworks.com/matlabcentral/answers/263934-every-time-i-push-to-the-remote-github-repository-i-have-to-re-input-my-username-and-password-is-t
Yet, when I try to push a commit, I get the following error message:
git@github.com:username/repository.git: invalid privatekey: **********
(There are some characters instead of the **********)
I'm running MATLAB R2017b on a MacBook Pro 15" 2018 with MacOS Mojave 10.14.2
I also have a config file inside my .ssh folder with the following text:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
The contents of my id_rsa.pub are on my GitHub account's SSH keys.
Does anybody know a solution for this issue?Javier Montemayorhttps://in.mathworks.com/matlabcentral/profile/authors/8501444-javier-montemayortag:in.mathworks.com,2005:Question/4870492019-10-23T17:25:54Z2019-10-23T17:25:54ZHDF5 transpose data?I have a HDF5 file called "output.h5" and it have a dataset called "density" which is a matrix with 21 rows and 2 cols.
I read this HDF5 dataset, but I got the transposed version of my density matrix (2 rows, 21 cols). Why? How can I solve it?
Here is my HDF5 dump of this file:
h5dump output.h5
HDF5 "output.h5" {
GROUP "/" {
GROUP "my" {
GROUP "path" {
GROUP "to" {
DATASET "density" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 21, 2 ) / ( 21, 2 ) }
DATA {
(0,0): 0, 2,
(1,0): 1, 2,
(2,0): 2, 4,
(3,0): 3, 8,
(4,0): 4, 14,
(5,0): 5, 22,
(6,0): 6, 32,
(7,0): 7, 44,
(8,0): 8, 58,
(9,0): 9, 74,
(10,0): 10, 92,
(11,0): 11, 112,
(12,0): 12, 134,
(13,0): 13, 158,
(14,0): 14, 184,
(15,0): 15, 212,
(16,0): 16, 242,
(17,0): 17, 274,
(18,0): 18, 308,
(19,0): 19, 344,
(20,0): 20, 382
}
}
}
}
}
}
}
ThanksNycholas Maiahttps://in.mathworks.com/matlabcentral/profile/authors/8458420-nycholas-maiatag:in.mathworks.com,2005:Question/4870332019-10-23T15:08:04Z2019-10-23T17:17:17ZHow to select a value in a matrix based on a pair of vectors?For Example:
We have vectors:
girls boys
2 6
7 5
5 4
4 3
3 3
6 2
8 1
1 6
2 6
And a matrix C:
8 42 37 33 29 25
7 45 39 33 29 25
6 48 40 33 28 24
girls 5 50 40 33 27 24
4 49 38 31 26 22
3 43 34 27 23 19
2 32 25 20 16 13
1 15 11 8 6 5
1 2 3 4 5 6
boys
I would like to make a vector D where I take the value of the matrix C wich is referent to the pair of vectors girls and boys. For example:
girls boys vector D
2 6 48
7 5 29
5 4 33
4 3 38
3 3 34
ect...Francisco Franciscohttps://in.mathworks.com/matlabcentral/profile/authors/15507093-francisco-franciscotag:in.mathworks.com,2005:Question/4870472019-10-23T17:16:41Z2019-10-23T17:16:41Zadding the GLCM features and get the energy and contrast features)dear brothers and sisters
i am new student in matlab i have a task that dataset (contains 2 categories, each has 50 image),
i -calculate the same features as above for each image
2- divide the data into 25 images train and 25 images test for each category
3- calculate the % correct in retrieving the nearest image for each query
4- adding the GLCM features (divide the image into 16-by-16 blocks, and for each block get the energy and contrast features)
5- Also, try to use the PCA
----------------------------------------------
i finsh points (1,2,3)
how can i applay GLCM and PCA
ANY ONE HELP
i will uploud a part of my code which solve points (1,2,3) which we make it in two file
first file ---------------->
for iiii=1:50
iii = (jndex-1)*50 + iiii -1;
fileName1=strcat(num2str(iii,'%2d'),'.tif');
outputfile1=strcat(num2str(iii,'%2d'),'.feats');
fileName1=strcat(path,fileName1);
outputfileName=strcat(path,outputfile1);
%reading the image:
X= imread(fileName1);
Xg=rgb2gray(X);
%This is the DCT2 for the GRAY and we take the upper left DCT2 coefficients
%with a square of size K-by-K
Xg=im2double(Xg);
Jg = dct2(Xg);
jg=im2col(Jg,[K K],'distinct'); %if K=12 this gives a vector length 144
bg = jg(:,1);
%For K=40, this will give 1600 features
%Here we get each color channel alone
y1=X(:,:,1); %Red
y2=X(:,:,2); %Green
y3=X(:,:,3); %Blue
Y1=im2double(y1);
Y2=im2double(y2);
Y3=im2double(y3);
%Now for the global color histograms for each separate color channel
h1 = imhist(Y1,KK); %red histogram
h2 = imhist(Y2,KK); %green histogram
h3 = imhist(Y3,KK); %blue histogram
%each histo has only KK bins (chosen to be 16 here)
h=[h1; h2; h3]; %here we concatenate the 3 histos from the 3 colors
%this makes 3*16 = 48 features in this case
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Now we have the color histogram for the combined colors using the color
%MAP. This color map was obtained from a collection of one image from each
%category. The MAP has
Xind = rgb2ind(X,MAP); %this transforms the image to an indexed image using the total map
UU = imhist(Xind,MAP); %this is the KKK vector with the combined colors histogram
%here KKK=256 giving 256 features
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
D= [bg; h; UU]; %the concatenated super vector
%So, total number of features is 144+48+256 = 448 features.
L = length(D);
ind=ind+1;
Data(ind,1:L)=D(1:L);
end
save(outputfileName3,'Data','-ASCII'); %this saves one feature file for each category
%in the same folder that this file is working from.
end
abdallah seraghttps://in.mathworks.com/matlabcentral/profile/authors/16614806-abdallah-seragtag:in.mathworks.com,2005:Question/4870382019-10-23T15:50:26Z2019-10-23T17:13:44Zrecall updated vector from a loopI have a column vector "displacement" with 18 elements, which is updated at every iteration (Nsteps) in a loop.
I would like to obtain a matrix such that each column is the displacement vector at each iteration. How can I do this?Gaetano Pavonehttps://in.mathworks.com/matlabcentral/profile/authors/7331525-gaetano-pavonetag:in.mathworks.com,2005:Question/4853412019-10-15T01:50:19Z2019-10-23T17:11:46ZError in matlab included deep learning exampleI am trying to run the matlab example
openExample('nnet/SeqToSeqClassificationUsing1DConvAndModelFunctionExample')
In 2019b but, when i change to train the network on gpu the example show me this error. Please help me to run it or give me a workaround to train using gpu.
Error using gpuArray/subsasgn
Attempt to grow array along ambiguous dimension.
Error in deep.internal.recording.operations.ParenAssignOp/forward (line 45)
x(op.Index{:}) = rhs;
Error in deep.internal.recording.RecordingArray/parenAssign (line 29)
x = recordBinary(x,rhs,op);
Error in dlarray/parenAssign (line 39)
objdata(varargin{:}) = rhsdata;
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample>maskedCrossEntropyLoss (line 484)
loss(i) = crossentropy(dlY(:,i,idx),dlT(:,i,idx),'DataFormat','CBT');
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample>modelGradients (line 469)
loss = maskedCrossEntropyLoss(dlY, dlT, numTimeSteps);
Error in deep.internal.dlfeval (line 18)
[varargout{1:nout}] = fun(x{:});
Error in dlfeval (line 40)
[varargout{1:nout}] = deep.internal.dlfeval(fun,varargin{:});
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample (line 284)
[gradients, loss] = dlfeval(@modelGradients,dlX,Y,parameters,hyperparameters,numTimeSteps);
Thanks!Javier Bushhttps://in.mathworks.com/matlabcentral/profile/authors/15828848-javier-bushtag:in.mathworks.com,2005:Question/4870412019-10-23T16:24:15Z2019-10-23T17:08:29ZError Index exceeds the number of array elements (151).I can't understand why matlab keeps enlarging k at each cicle so i can't use the while loop.
x = 0:1:150;
y = x+1;
k=1;
while y(k+1)-y(k)>eps
k=k+1;
end
Federico Draettahttps://in.mathworks.com/matlabcentral/profile/authors/16266036-federico-draettatag:in.mathworks.com,2005:Question/4869412019-10-23T07:29:55Z2019-10-23T17:04:56ZHow to use GlobalSearch to find global minimumHi,
I have successfully used fmincon to find a solution to my optimization problem. The solution is a local minimum (but could be global).
Now I want to find the global minimum. I have seen the procedure in MATLAB documentation, but when I try to write
>> help globalsearch
globalsearch not found.
Do I need to downlaod anything to run global search? my version is MATLAB R2019b.
ThanksAhmed Ghamdihttps://in.mathworks.com/matlabcentral/profile/authors/15509041-ahmed-ghamditag:in.mathworks.com,2005:Question/4870452019-10-23T04:00:00Z2019-10-23T17:02:15ZHow do I publish high-quality, well-scaled figures and output to a PDF?I have a script that generates screen output and a bunch of figures. I wish to generate a PDF report which consists of the console output and high quality (well-scaled) figures. Now, I've been able to generate the console output + low-quality (not well scaled) images using the 'publish' command. I have also been able to save well-scaled version of each figure as a separate PDF using the print('-fillpage'..) command. Is there a way in which I can:
a) suppress printing of figures in the publish command
b) concatenate all PDFs together after the console output and high quality images have been printed
c) print to the console output at the same time as publish is being executed
MathWorks Support Teamhttps://in.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:in.mathworks.com,2005:Question/4864492019-10-20T19:02:42Z2019-10-23T16:48:42ZPlease help me to using genetic algorithmI write this code but I want to solve this problem with 'ga' not with 'intlinprog' solver!
Can anyone guide me?
costprob = optimproblem;
% Indices
k = 15;
j = 2;
f = 10;
l = 5;
r0 = 6;
r = 6;
% Parameters
cr0 = 0 + 1*rand(1,r0);
dr0f = 0 + 1*rand(r0,f);
csl = 0 + 1*rand(1,l);
DE = 200 + 100*rand(1,1);
csur0f = 2000 + 1000*rand(r0,f);
ctl = 1000 + 1000*rand(1,l);
cvl = 10 + 10*rand(1,l);
cpjk = 0 + 1*rand(j,k);
corj = 0 + 1*rand(r,j);
pr0f = 0 + 1*rand(r0,f);
vjk = 0 + 1*rand(j,k);
cvjrk = 0 + 1*rand(j,r,k);
M = 10000000000000;
% Variables
xl = optimvar('xl',1,l,'LowerBound',0);
yr0f = optimvar('yr0f',r0,f,'Type','integer','LowerBound',0,'UpperBound',1);
xx1r0f = optimvar('xx1r0f',r0,f,'LowerBound',0);
xx2r0f = optimvar('xx2r0f',r0,f,'LowerBound',0);
yjk1 = optimvar('yjk1',j,k,'Type','integer','LowerBound',0,'UpperBound',1);
yl2 = optimvar('yl2',1,l,'Type','integer','LowerBound',0,'UpperBound',1);
zjkr = optimvar('zjkr',j,k,r,'LowerBound',0);
wrj = optimvar('wrj',r,j,'LowerBound',0);
% Objective function
objfun1 = sum(sum(dr0f.*xx1r0f,2).*cr0',1);
objfun2 = sum(sum(corj.*wrj,2),1);
objfun3 = sum(sum(pr0f.*xx1r0f,2),1);
objfun4 = sum(sum(cpjk.*yjk1,2),1);
objfun5 = sum(csl.*xl,2);
costprob.Objective = objfun1 + objfun2 + objfun3 + objfun4 + objfun5;
% Constraints
cons1 = sum(xl,2) >= DE;
cons2 = sum(xl,2)*ones(j,1,r) == sum(zjkr,2);
cons3 = xx1r0f <= csur0f.*yr0f;
cons4 = xl <= ctl.*yl2;
cons5 = xl >= cvl.*yl2;
cons6 = sum(yjk1,2) == ones(j,1);
cons7 = squeeze(sum(zjkr,3)) <= M*yjk1;
cons8 = (1-dr0f).*xx1r0f == xx2r0f;
costprob.Constraints.cons1 = cons1;
costprob.Constraints.cons2 = cons2;
costprob.Constraints.cons3 = cons3;
costprob.Constraints.cons4 = cons4;
costprob.Constraints.cons5 = cons5;
costprob.Constraints.cons6 = cons6;
costprob.Constraints.cons7 = cons7;
costprob.Constraints.cons8 = cons8;S AsZhttps://in.mathworks.com/matlabcentral/profile/authors/16431168-s-asztag:in.mathworks.com,2005:Question/14272011-02-16T09:53:30Z2019-10-23T16:31:25ZWhat frustrates you about MATLAB?I love MATLAB. It is so quick and easy to write software to do what you want. It has excellent debugging and profiling tools. It is cross platform, making code easy to share (assuming the other people have forked out for the not-so-cheap license). It has interfaces to other software.
However, there are some things about it that irk me. I'd like to hear from other people what things annoy them about MATLAB.Oliver Woodfordhttps://in.mathworks.com/matlabcentral/profile/authors/1073021-oliver-woodfordtag:in.mathworks.com,2005:Question/4870432019-10-23T16:30:47Z2019-10-23T16:31:24ZPID Control of DC motors using Simulink hardware support for arduinoI'm trying to create a Control System using Symulink that helps syncronizing the motion of two DC motors using Simulink hardware support for arduino from MATLAB R2019a. I used two encoder wheels and two optointerruptes, whose signal I expected to process in order to get the rotation angle of the motors.
The subsystems MOTOR are configured as follows:
The INX pins correspond to IN pins of an L293D H bridge. The pins ENA, ENB are the enable pins accordingly. The ENCA, ENCB pins read the pulsating signal from the optointerrupters. By counting the number of pull-ups or pull-downs of the pulsating signal of the optointerrupters, I expected to characterize the motion of the motors as a function of time.
My idea was to set the motion of a motor to fixed velocity using a fixed PWM argument for the enB input in MOTORB. Then, using a PI control, I expected to adjust the motion of the MOTORA to that of the MOTORB. My model is included in the figure. Both counters are set to trigger at both edges.
In the socpes I was able to see the results of my model when run in extenal mode on an arduino 2560 R3, using FixedStepDiscrete solver with automatic step:
Apparently, the control system works, because the two outputs of the COUNTA and COUNTB are very similar. However, when I monitor the PWM input for the MOTORA, I get a completelly different result. The motors do not behave nearly similar. In fact, whereas the MOTORB behaves like shown in actuallity, the MOTORA performs a chaotic motion that in no way resembles the motion depicted above. How is that possible? How can I modify my model to accuratelly measure the motion of the motor using the optointerrupters? How can I modify the model in order to obtain a result similar to that of the picture above but in the real life?Diego Alejandro Herrera Rojashttps://in.mathworks.com/matlabcentral/profile/authors/15914958-diego-alejandro-herrera-rojastag:in.mathworks.com,2005:Question/4870352019-10-23T15:28:53Z2019-10-23T16:29:15ZBuilding Function for PercentageHello. For my client, want to build function in Matlab for 1 scaler input (speed limit for circuit) and 1 scaler input (speed of some signals around circuit). The first input is speed limit of circuit. The second input is the speed of the signals around circuit. I want to calculate the percentage difference between the speed limit and the signals but I am not sure how to do this - how? Second, I want to then build a function using the percentage difference value between these two variables-for example, if percentage difference is more than X%, display 'good'. Please help. Thanks :)Yung Xihttps://in.mathworks.com/matlabcentral/profile/authors/16659772-yung-xi