## (Liblinear) Error: C <= 0

I'm getting the following error from Liblinear while trying to train an SVM: 'Error: C<= 0'. Although it's obvious what's wrong, I can't figure out why there is a problem, since the C I find through cross validation is positive.This is the cross validation code (I have removed the lower bit) for finding Cfor log2c = 2:1:6,cmd = ['-s 2 -v 5 -c ', num2str(2^log2c)];cv = train(labels, features, cmd);and the result I get isCross Validation Accuracy = 91.6772%bestc = 4, cv = 91.6772However when I then train the SVM I get models{i} = train(trainLabel, trainFeats, ['-s 2 -c ', ...

## Matlab fft2 anomaly (bug or stupid user error?)

In trying to replicate an optical Fourier transform within Matlab I did the following:I loaded this 512x512 image as "dot512r": Then did: >> whos dot512r Name Size Bytes Class Attributes dot512r 512x512x3 786432 uint8 >> bwimg=rgb2gray(dot512r); >> whos bwimg Name Size Bytes Class Attributes bwimg 512x512 262144 uint8 >> ftimg=fft2(bwimg); >> figure >> imshow(log(fftshift(ftimg))/10.0);Which results in this image (so f...

## How to display table in parts in command window in matlab?

I have a table which consists of 17025 rows. When I try to display the table, the whole table displays. But I want it in small parts. How do I make it display in small parts. Type more on at the MATLAB command prompt. Subsequent output will be paused after every screenful.Documentation: https://www.mathworks.com/help/matlab/ref/more.html [XXX]I usually check my variables in these ways:Suppose that we have a variable called A=rand(1000,1000).1.we can display a part of A by calling A(127:130,241:243), to show the specific part of it.>> A(127:130,241:243)ans = 0...

## How can I display a grayscale raster in color in Matlab?

I have a .tif file of a landmass that denotes elevation. I want to display this raster with a color ramp as opposed to a grayscale ramp. How would I do this in Matlab?I looked at the information associated with the tiff using:[Z, R] = geotiffread('Landmass.tif')which denotes the heading 'ColourType' as 'grayscale'. I tried to change this to 'winter' (one of matlabs in-built color schemes) but it made no difference.At the moment I am using the following commands to display the tiff:[Z, R] = geotiffread('Landmass.tif');e=uint8(Z);mapshow(e,R);All the higher areas are white an...

## Solving nonlinear system of differential equations in matlab usin ODE45

i am trying to solve a system of nonlinear differential equation using ODE45 MATLAB , i did that many times successfully , but this time i get the following error and i really don't know what is wrong i am confused compeletly. here are the codes.%% this is the error: Subscript indices must either be real positive integers or logicals.Error in non_L_ss (line 6) (-Fk*(ds0+x(3)-x(1))+Fk*ds0-Fc(x(4)-x(2)))/ms +Fa/ms ] ;Error in odearguments (line 87)f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.Error in ode45 (line 115)odearguments(FcnHandlesUsed,solver_...

## Matlab min equivalent in OpenCV

I'm looking for an equivalent for the min function of Matlab in OpenCV, with this particular functionality (taken from the official Matlab documentation): [M,I] = min(___) finds the indices of the minimum values of A and returns them in output vector I, using any of the input arguments in the previous syntaxes. If the minimum value occurs more than once, then min returns the index corresponding to the first occurrence.In my specific case, I have 2 images. I want to create a new image with the minimum value of each pixel (wrt those 2 images), and I need to store a ma...

## Why does changing the Variable Name of a Table not work if it's the Property of a Class?

In the past, I've been making extensive use of Matlab's table class.This very simple code, inside a script or at the prompt, works as expected:varNames = {'Date_time', 'Concentration_1', 'Concentration_2'};testTable = array2table(zeros(5,3), 'VariableNames', varNames)Now, I have the same table as the property of a handle class.classdef TestClass < handle properties testTable (:,3) table end methods function testMethod(obj) varNames = {'Date_time', 'Concentration_1', 'Concentration_2'}; obj.testTable = array2table(zeros(5,3), '...

## Filling an area above a curve with many colors (matlab, surf)

I'm trying to create a figure in matlab that looks like this:desired figureI am doing so by: (i) assigning value points to each x,y coordinate, (ii) plotting a surf, and (iii) change the view point so the third axis is not seen. Here is the code: x = linspace(0, 1, 10); y = linspace(0, 1, 10); z = linspace(0, 1, 10); z = repmat(z, 10, 1); z = flipud(triu(z)); z(z==0) = nan; hold off surf(x, y, z, 'linestyle', 'none') colormap([linspace(0.39, 1, 20)',linspace(0.58, 0.25, 20)', linspace(0.93, 0.25, 20)']); colorbar xlim([x(1) x(end)]) shadi...

## Error when passing arguments to function handles

Suppose we have the following function:function f=lorenz(t,x,a,b,c) % solve differential equation like this %dx/dt=a*(y-x) %dy/dt=-x*z+b*x-y %dz/dt=xy-c*z/3 f=zeros(3,1);% preallocate result f(1)=a*(x(2)-x(1)); f(2)=-x(1)*x(3)+b*x(1)-x(2); f(3)=x(1)*x(2)-c*x(3)/3; endFor running this program, let us use the following test file:% test programx0=[-2 -3.5 21];% initial pointa=input(' enter first coefficient : ');b=input(' enter second coefficient: ');c=input(' enter third coefficient : ');[t,x]=ode45(@(x) lorenz(x,a,b,c),[0 10],x0);plot(t,x(:,1),'r'...

## How would you perform inter-row operations based on multiple columns? MATLAB

I am a novice programmer that is primarily self-taught. I am new to MATLAB and relational mathematics. Currently, I am attempting to perform math operations between rows. I would like to normalize the exp by the corresponding con and then multiply by the constant. This constant is a laboratory measurement that could be subject to change in future experments. Thus, I have given it a column.Below is some sample code that I have generated to exemplify my problem and solution. I am trying to get from myTable to rTable.I recognize my solution is very sloppy and there must be a w...

## What plotting software to use: 2D polar plot with unique data

I have my (example) data in the following format:R_min R_max θ_min θ_min Zones0 260 0 1.57 114260 270 0 1.57 106270 320 0 1.57 107As you can see, I have "zones" (areas) that are created from R_min to R_max that sweep from theta_min to theta_max. Each row of data represents an area that I want to plot with a corresponding color based on the zone number. In this simple case, the data I show above would look like the following picture:What plotting software should I use to accomplish this? I have been investigating the following options:MATLAB. I am hav...

## Introduce Multiple Background Colors In Matlab GUI slider

I am trying to color just some parts of the slider of my matlab GUI in order to locate where some events in time occur in there. I know that the command in order to change the COMPLETE background color of the slider is:set(handles.slider,'backgroundcolor','red');Does anyone know how to change just some part of the background color. Thanks for the help. Thanks, it seems that it cannot be done in the way I wanted to do. Finally I created the detection with a plot of a timeline axis like the next one:it can be seen in the right down parthandles.ax=axes('NextPlot','add',... ...

## Solving a system of ODEs using ODE45

I am trying to learn how to use MATLAB to solve a system of differential equations (Lorenz equations) and plot each solution as a function of tX’ = −σx + σy Y’ = ρx − y − xzZ’ = −βz + xywhere σ = 10, β = 8/3, and ρ = 28, as well as x(0) = −8, y(0) = 8, and z(0) = 27. Here is the code that I am using:function xprime = example(t,x)sig = 10;beta = 8/3;rho = 28;xprime = [-sig*x(1) + sig*x(2); rho*x(1) - x(2) - x(1)*x(3); -beta*x(3) + x(1)*x(2)];x0 = [-8 8 27]; tspan = [0 20]; [t,x] = ode45(@example, tspan, x0);figure plot(t,x(:,1)), hold onplot(...

## Fastest way to convert numerical table values to character arrays

I have a table which contains various data types. For instance,chars = {'a'; 'bc'; 'de'};nums = [1; 20; 300];tbl = table(chars, nums);I want to convert all numerical columns to character array variables. By this, I mean the result should be equivalent to if I had initialised the table using:nums = {'1'; '20', '300'};tbl = table(chars, nums); I want to do this as fast as possible because I have a table with potentially millions of rows.Current working solutions:Firstly, I get the numerical columns, in the case of this example this will be column 2...% Get the columns numbers...

## Matlab: How to plot without color graduation?

My friend has made a script to handle a lot of data and plot various plots, however when he runs the script, the graphs have different colors according to the legend and when I do it, all graphs are similar with a color graduation from black to red! (see picture) Why does it differ and how do I get the graphs in different colors?2D plot with color graduated graphs:-figurehold onplot(sentar_7.created_at, sentar_7.acc_diff, '-');plot(sentar_7.created_at, sentar_7.stand_toggle, '-');plot(sentar_7.created_at, sentar_7.state, '-');title('Sentar 7 acc')xlabel('tid')ylabel('dist [...

## ODE45 with very large numbers as constraints

2nd ODE to solve in MATLAB: ( (a + f(t))·d²x/dt² + (b/2 + k(t))·dx/dt ) · dx/dt - g(t) = 0Boundary condition: dx/dt(0) = v0wheret is the time, x is the positiondx/dt is the velocityd2x/dt2 is the accelerationa, b, v0 are constantsf(t), k(t) and h(t) are KNOWN functions dependent on t(I do not write them because they are quite big)As an example, using symbolic variables:syms t y%% --- Initial conditions --- phi = 12.5e-3; v0 = 300; e = 3e-3; ro = 1580; E = 43e9; e_r = 0.01466; B = 0.28e-3; %% --- Intermediate calculatio...

**Page 1 of 200 | ****Show More Pages: **Top
Prev
Next
Last