Tag Archives: matlab
How to plot one curve and change color according to value
The tricky thing is that I get an attribute with the values and would like to have this part in the plot in a different color:
x = linspace(0,10);
y = sin(3*x).*exp(0.5*x);
c = find(y > 25);
m(length(x)) = 0;
m(c) = 1;
figure;
plot(x, y, ‘b’)
Where m becomes 1 the color should be red, else blue.
Can someone find the easiest way to do this?The tricky thing is that I get an attribute with the values and would like to have this part in the plot in a different color:
x = linspace(0,10);
y = sin(3*x).*exp(0.5*x);
c = find(y > 25);
m(length(x)) = 0;
m(c) = 1;
figure;
plot(x, y, ‘b’)
Where m becomes 1 the color should be red, else blue.
Can someone find the easiest way to do this? The tricky thing is that I get an attribute with the values and would like to have this part in the plot in a different color:
x = linspace(0,10);
y = sin(3*x).*exp(0.5*x);
c = find(y > 25);
m(length(x)) = 0;
m(c) = 1;
figure;
plot(x, y, ‘b’)
Where m becomes 1 the color should be red, else blue.
Can someone find the easiest way to do this? plot, changing color MATLAB Answers — New Questions
Source code for solving second order PDE using PINN
Hi
Can someone share the matlab source code for solving second order ODE of the type as below?
I could build a sample code using : https://uk.mathworks.com/help/deeplearning/ug/solve-partial-differential-equations-with-lbfgs-method-and-deep-learning.html#responsive_offcanvas
But, I am not sure how to input the IC of the form d/dx() in the code.
All help will be appreciated.
ThanksHi
Can someone share the matlab source code for solving second order ODE of the type as below?
I could build a sample code using : https://uk.mathworks.com/help/deeplearning/ug/solve-partial-differential-equations-with-lbfgs-method-and-deep-learning.html#responsive_offcanvas
But, I am not sure how to input the IC of the form d/dx() in the code.
All help will be appreciated.
Thanks Hi
Can someone share the matlab source code for solving second order ODE of the type as below?
I could build a sample code using : https://uk.mathworks.com/help/deeplearning/ug/solve-partial-differential-equations-with-lbfgs-method-and-deep-learning.html#responsive_offcanvas
But, I am not sure how to input the IC of the form d/dx() in the code.
All help will be appreciated.
Thanks pinn MATLAB Answers — New Questions
Nondimensionalizing Length and Temp data from 2-D Ansys Transient thermal in Matlab
I have a text file that has dimensionalized data from Ansys (in micron and Kelvin). The first column is length and the second column is temperature. I am trying to nondimensionalize these data points and then put them in a graph where the x-axis represents nondimensionalized length and the y-axis represends nondimensionalized temperature.
xs = 100µm
Tf = 500K
Ti = 300K
How do I nondimensionalize this properly?I have a text file that has dimensionalized data from Ansys (in micron and Kelvin). The first column is length and the second column is temperature. I am trying to nondimensionalize these data points and then put them in a graph where the x-axis represents nondimensionalized length and the y-axis represends nondimensionalized temperature.
xs = 100µm
Tf = 500K
Ti = 300K
How do I nondimensionalize this properly? I have a text file that has dimensionalized data from Ansys (in micron and Kelvin). The first column is length and the second column is temperature. I am trying to nondimensionalize these data points and then put them in a graph where the x-axis represents nondimensionalized length and the y-axis represends nondimensionalized temperature.
xs = 100µm
Tf = 500K
Ti = 300K
How do I nondimensionalize this properly? nondimensionalize, matlab, text file, data, temperature, length, graph MATLAB Answers — New Questions
Solving trigonometric simultaneous equations
Is it possible to solve when the equations are little complex? For example lets’s take an inverse kinematics problem. Where we get,
-0.2595 0.5536 0.7913 0.3004 r11 r12 r13 o1
-0.7781 -0.6052 0.1682 0.0639 = r21 r22 r23 o2
0.5721 -0.5721 0.5878 0.6167 r31 r32 r33 o3
0 0 0 1 0 0 0 0
each of these symbols represents a trigonometric function such as below. Need to find θ1,θ2,θ3,θ4,θ5
[ sin(theta1)*sin(theta5) – cos(theta5)*(cos(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)) + sin(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2))), cos(theta5)*sin(theta1) + sin(theta5)*(cos(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)) + sin(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2))), cos(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2)) – sin(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)), (1143*cos(theta1)*cos(theta2))/5000 + (127*cos(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2)))/1600 – (127*sin(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)))/1600 – (1143*cos(theta1)*sin(theta2)*sin(theta3))/5000 + (1143*cos(theta1)*cos(theta2)*cos(theta3))/5000]
[ – cos(theta1)*sin(theta5) – cos(theta5)*(cos(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)) + sin(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2))), sin(theta5)*(cos(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)) + sin(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2))) – cos(theta1)*cos(theta5), cos(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2)) – sin(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)), (1143*cos(theta2)*sin(theta1))/5000 + (127*cos(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2)))/1600 – (127*sin(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)))/1600 – (1143*sin(theta1)*sin(theta2)*sin(theta3))/5000 + (1143*cos(theta2)*cos(theta3)*sin(theta1))/5000]
[ cos(theta5)*(cos(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) + sin(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3))), -sin(theta5)*(cos(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) + sin(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3))), sin(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) – cos(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3)), (1143*sin(theta2))/5000 + (1143*cos(theta2)*sin(theta3))/5000 + (1143*cos(theta3)*sin(theta2))/5000 – (127*cos(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3)))/1600 + (127*sin(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)))/1600 + 4953/20000]
[ 0, 0, 0, 1]
Is matlab capable of solving such equations?
Thank you.Is it possible to solve when the equations are little complex? For example lets’s take an inverse kinematics problem. Where we get,
-0.2595 0.5536 0.7913 0.3004 r11 r12 r13 o1
-0.7781 -0.6052 0.1682 0.0639 = r21 r22 r23 o2
0.5721 -0.5721 0.5878 0.6167 r31 r32 r33 o3
0 0 0 1 0 0 0 0
each of these symbols represents a trigonometric function such as below. Need to find θ1,θ2,θ3,θ4,θ5
[ sin(theta1)*sin(theta5) – cos(theta5)*(cos(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)) + sin(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2))), cos(theta5)*sin(theta1) + sin(theta5)*(cos(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)) + sin(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2))), cos(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2)) – sin(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)), (1143*cos(theta1)*cos(theta2))/5000 + (127*cos(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2)))/1600 – (127*sin(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)))/1600 – (1143*cos(theta1)*sin(theta2)*sin(theta3))/5000 + (1143*cos(theta1)*cos(theta2)*cos(theta3))/5000]
[ – cos(theta1)*sin(theta5) – cos(theta5)*(cos(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)) + sin(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2))), sin(theta5)*(cos(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)) + sin(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2))) – cos(theta1)*cos(theta5), cos(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2)) – sin(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)), (1143*cos(theta2)*sin(theta1))/5000 + (127*cos(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2)))/1600 – (127*sin(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)))/1600 – (1143*sin(theta1)*sin(theta2)*sin(theta3))/5000 + (1143*cos(theta2)*cos(theta3)*sin(theta1))/5000]
[ cos(theta5)*(cos(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) + sin(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3))), -sin(theta5)*(cos(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) + sin(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3))), sin(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) – cos(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3)), (1143*sin(theta2))/5000 + (1143*cos(theta2)*sin(theta3))/5000 + (1143*cos(theta3)*sin(theta2))/5000 – (127*cos(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3)))/1600 + (127*sin(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)))/1600 + 4953/20000]
[ 0, 0, 0, 1]
Is matlab capable of solving such equations?
Thank you. Is it possible to solve when the equations are little complex? For example lets’s take an inverse kinematics problem. Where we get,
-0.2595 0.5536 0.7913 0.3004 r11 r12 r13 o1
-0.7781 -0.6052 0.1682 0.0639 = r21 r22 r23 o2
0.5721 -0.5721 0.5878 0.6167 r31 r32 r33 o3
0 0 0 1 0 0 0 0
each of these symbols represents a trigonometric function such as below. Need to find θ1,θ2,θ3,θ4,θ5
[ sin(theta1)*sin(theta5) – cos(theta5)*(cos(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)) + sin(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2))), cos(theta5)*sin(theta1) + sin(theta5)*(cos(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)) + sin(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2))), cos(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2)) – sin(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)), (1143*cos(theta1)*cos(theta2))/5000 + (127*cos(theta4)*(cos(theta1)*cos(theta2)*sin(theta3) + cos(theta1)*cos(theta3)*sin(theta2)))/1600 – (127*sin(theta4)*(cos(theta1)*sin(theta2)*sin(theta3) – cos(theta1)*cos(theta2)*cos(theta3)))/1600 – (1143*cos(theta1)*sin(theta2)*sin(theta3))/5000 + (1143*cos(theta1)*cos(theta2)*cos(theta3))/5000]
[ – cos(theta1)*sin(theta5) – cos(theta5)*(cos(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)) + sin(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2))), sin(theta5)*(cos(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)) + sin(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2))) – cos(theta1)*cos(theta5), cos(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2)) – sin(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)), (1143*cos(theta2)*sin(theta1))/5000 + (127*cos(theta4)*(cos(theta2)*sin(theta1)*sin(theta3) + cos(theta3)*sin(theta1)*sin(theta2)))/1600 – (127*sin(theta4)*(sin(theta1)*sin(theta2)*sin(theta3) – cos(theta2)*cos(theta3)*sin(theta1)))/1600 – (1143*sin(theta1)*sin(theta2)*sin(theta3))/5000 + (1143*cos(theta2)*cos(theta3)*sin(theta1))/5000]
[ cos(theta5)*(cos(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) + sin(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3))), -sin(theta5)*(cos(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) + sin(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3))), sin(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)) – cos(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3)), (1143*sin(theta2))/5000 + (1143*cos(theta2)*sin(theta3))/5000 + (1143*cos(theta3)*sin(theta2))/5000 – (127*cos(theta4)*(cos(theta2)*cos(theta3) – sin(theta2)*sin(theta3)))/1600 + (127*sin(theta4)*(cos(theta2)*sin(theta3) + cos(theta3)*sin(theta2)))/1600 + 4953/20000]
[ 0, 0, 0, 1]
Is matlab capable of solving such equations?
Thank you. solve MATLAB Answers — New Questions
Can’t find vehicleDatasetImages.zip
I’m trying to use the dataset ‘vehicleDatasetImages’, but the function unzip returns this error:
Error using matlab.io.internal.archive.checkFilename>throwFileNotFoundError (line 156)
Function UNZIP was unable to find file ”vehicleDatasetImages.zip”.
What can I do?I’m trying to use the dataset ‘vehicleDatasetImages’, but the function unzip returns this error:
Error using matlab.io.internal.archive.checkFilename>throwFileNotFoundError (line 156)
Function UNZIP was unable to find file ”vehicleDatasetImages.zip”.
What can I do? I’m trying to use the dataset ‘vehicleDatasetImages’, but the function unzip returns this error:
Error using matlab.io.internal.archive.checkFilename>throwFileNotFoundError (line 156)
Function UNZIP was unable to find file ”vehicleDatasetImages.zip”.
What can I do? data, deep learning, object detection MATLAB Answers — New Questions
Permanent magnets in PDE toolbox
Dear all,
How do I describe a permanent magnet in the PDE toolbox ?
I could find nothing in electromagneticProperties or electromagneticSourceDear all,
How do I describe a permanent magnet in the PDE toolbox ?
I could find nothing in electromagneticProperties or electromagneticSource Dear all,
How do I describe a permanent magnet in the PDE toolbox ?
I could find nothing in electromagneticProperties or electromagneticSource pde magnetostatics magnet MATLAB Answers — New Questions
power Load flow equations
constraints=[Costraints,Pg(1,1)-Pd(1,1)==vmag(1,1)*[vmag(1,1)*Ymag(1,1)*cos(Yang(1,1))+…
vmag(1,2)*Ymag(2,1)*cos(Yang(2,1) + vang(1,1) – vang(1,2))+…
vmag(1,3)*Ymag(3,1)*cos(Yang(3,1) + vang(1,1) – vang(1,3))+…
vmag(1,4)*Ymag(4,1)*cos(Yang(4,1) + vang(1,1) – vang(1,4))]; Constraints=[Costraints,Qg(1,1)-Qd(1,1)==(-vmag(1,1))*[vmag(1,1)*Ymag(1,1)*sin(Yang(1,1))+..
vmag(1,2)*Ymag(2,1)*sin(Yang(2,1) + vang(1,1) – vang(1,2))+…
vmag(1,3)*Ymag(3,1)*sin(Yang(3,1) + vang(1,1) – vang(1,3))+…
vmag(1,4)*Ymag(4,1)*sin(Yang(4,1) + vang(1,1) – vang(1,4))];constraints=[Costraints,Pg(1,1)-Pd(1,1)==vmag(1,1)*[vmag(1,1)*Ymag(1,1)*cos(Yang(1,1))+…
vmag(1,2)*Ymag(2,1)*cos(Yang(2,1) + vang(1,1) – vang(1,2))+…
vmag(1,3)*Ymag(3,1)*cos(Yang(3,1) + vang(1,1) – vang(1,3))+…
vmag(1,4)*Ymag(4,1)*cos(Yang(4,1) + vang(1,1) – vang(1,4))]; Constraints=[Costraints,Qg(1,1)-Qd(1,1)==(-vmag(1,1))*[vmag(1,1)*Ymag(1,1)*sin(Yang(1,1))+..
vmag(1,2)*Ymag(2,1)*sin(Yang(2,1) + vang(1,1) – vang(1,2))+…
vmag(1,3)*Ymag(3,1)*sin(Yang(3,1) + vang(1,1) – vang(1,3))+…
vmag(1,4)*Ymag(4,1)*sin(Yang(4,1) + vang(1,1) – vang(1,4))]; constraints=[Costraints,Pg(1,1)-Pd(1,1)==vmag(1,1)*[vmag(1,1)*Ymag(1,1)*cos(Yang(1,1))+…
vmag(1,2)*Ymag(2,1)*cos(Yang(2,1) + vang(1,1) – vang(1,2))+…
vmag(1,3)*Ymag(3,1)*cos(Yang(3,1) + vang(1,1) – vang(1,3))+…
vmag(1,4)*Ymag(4,1)*cos(Yang(4,1) + vang(1,1) – vang(1,4))]; Constraints=[Costraints,Qg(1,1)-Qd(1,1)==(-vmag(1,1))*[vmag(1,1)*Ymag(1,1)*sin(Yang(1,1))+..
vmag(1,2)*Ymag(2,1)*sin(Yang(2,1) + vang(1,1) – vang(1,2))+…
vmag(1,3)*Ymag(3,1)*sin(Yang(3,1) + vang(1,1) – vang(1,3))+…
vmag(1,4)*Ymag(4,1)*sin(Yang(4,1) + vang(1,1) – vang(1,4))]; optimization of reactive power MATLAB Answers — New Questions
Simscape multibody composite rigid body inertia
Howdy,
I’m working with simscape multibody and I’ve seen using inertia sensor there’s chance to select a local group of connected blocks or whole mechanicsms. I was wondering if for a complex branched mechanism would be possible to take also a composite rigid body inertia measure (using actual configurations given by joints positions) for single branches in palce of whole mechanism of any workaround exist for.
Cheers,
Soldà EnricoHowdy,
I’m working with simscape multibody and I’ve seen using inertia sensor there’s chance to select a local group of connected blocks or whole mechanicsms. I was wondering if for a complex branched mechanism would be possible to take also a composite rigid body inertia measure (using actual configurations given by joints positions) for single branches in palce of whole mechanism of any workaround exist for.
Cheers,
Soldà Enrico Howdy,
I’m working with simscape multibody and I’ve seen using inertia sensor there’s chance to select a local group of connected blocks or whole mechanicsms. I was wondering if for a complex branched mechanism would be possible to take also a composite rigid body inertia measure (using actual configurations given by joints positions) for single branches in palce of whole mechanism of any workaround exist for.
Cheers,
Soldà Enrico simscape, inertia measures, composite rigid body MATLAB Answers — New Questions
code for segmentation of image using grabcut algorithm
I=imread(‘Lenna.jpg’);
pad=3;
MAXVAL=255;
[Ncut] = graphcuts(I,pad,MAXVAL)
% function [Ncut] = graphcuts(I)
% Input: I image
% pad: spatial connectivity; eg. 3
% MAXVAL: maximum image value
% Output: Ncut: Binary map 0 or 1 corresponding to image segmentation
error :
Error using graph cuts
Not enough input arguments.I=imread(‘Lenna.jpg’);
pad=3;
MAXVAL=255;
[Ncut] = graphcuts(I,pad,MAXVAL)
% function [Ncut] = graphcuts(I)
% Input: I image
% pad: spatial connectivity; eg. 3
% MAXVAL: maximum image value
% Output: Ncut: Binary map 0 or 1 corresponding to image segmentation
error :
Error using graph cuts
Not enough input arguments. I=imread(‘Lenna.jpg’);
pad=3;
MAXVAL=255;
[Ncut] = graphcuts(I,pad,MAXVAL)
% function [Ncut] = graphcuts(I)
% Input: I image
% pad: spatial connectivity; eg. 3
% MAXVAL: maximum image value
% Output: Ncut: Binary map 0 or 1 corresponding to image segmentation
error :
Error using graph cuts
Not enough input arguments. grabcuts/ graphcuts MATLAB Answers — New Questions
Why would I encounter an error message about unsuitable bus signal using DDS Blockset?
Hi,
I encounter the error : " The ‘input port 1’ of ‘ddsblockset1/Outport’ requires a bus, but it receives a non bus signal from the ‘output port 1’ of ‘ddsblockset1/Write DDS Sample’."
The data type of the input and output ports has been selected as the "Dataype" defined by DDS. I don’t seem to have any difference from the official example settings. Why did I encounter an error?Hi,
I encounter the error : " The ‘input port 1’ of ‘ddsblockset1/Outport’ requires a bus, but it receives a non bus signal from the ‘output port 1’ of ‘ddsblockset1/Write DDS Sample’."
The data type of the input and output ports has been selected as the "Dataype" defined by DDS. I don’t seem to have any difference from the official example settings. Why did I encounter an error? Hi,
I encounter the error : " The ‘input port 1’ of ‘ddsblockset1/Outport’ requires a bus, but it receives a non bus signal from the ‘output port 1’ of ‘ddsblockset1/Write DDS Sample’."
The data type of the input and output ports has been selected as the "Dataype" defined by DDS. I don’t seem to have any difference from the official example settings. Why did I encounter an error? dds blockset, simulink, bus signal MATLAB Answers — New Questions
Domain sketch for multiple variables function
How do I sketch the domain of the function f(x,y) =dfrac{sqrt(y-x^2)}{(1-x^2)}
How to sketch domain D f(x,y)<=0 on Oxy?
This is for my exercise so I really need some help. Thanks in advanced!How do I sketch the domain of the function f(x,y) =dfrac{sqrt(y-x^2)}{(1-x^2)}
How to sketch domain D f(x,y)<=0 on Oxy?
This is for my exercise so I really need some help. Thanks in advanced! How do I sketch the domain of the function f(x,y) =dfrac{sqrt(y-x^2)}{(1-x^2)}
How to sketch domain D f(x,y)<=0 on Oxy?
This is for my exercise so I really need some help. Thanks in advanced! domain, sketch MATLAB Answers — New Questions
Read in part of large histological (ndpi) file
I want to read in a very large histological image file (file size: 2.05 GB, *.ndpi file, pixel size: 57856 x 1.111e+05) and don’t have enough RAM.
I tried blockedImage and thought it would fit great but still, I am unable to get my data in highest resolution.
I tried:
% p,f are path and filename for the 2.05 GB *.ndpi file
A = blockedImage(strcat(p,f));
levelSizeInfo = table((1:length(A.Size))’, …
A.Size(:,1), …
A.Size(:,2), …
A.Size(:,1)./A.Size(:,2), …
‘VariableNames’,["Resolution Level" "Image Width" "Image Height" "Aspect Ratio"])
and obtained
levelSizeInfo =
9×4 table
Resolution Level Image Width Image Height Aspect Ratio
________________ ___________ ____________ ____________
1 57856 1.111e+05 0.52074
2 28928 55552 0.52074
3 14464 27776 0.52074
4 7232 13888 0.52074
5 3616 6944 0.52074
6 1808 3472 0.52074
7 904 1736 0.52074
8 407 1188 0.34259
9 203 594 0.34175
So I want to assess the resolution level 1 information and therefore tried to split it up in smaller patches:
bls = selectBlockLocations(A,"Levels",1,"BlockSize",[4096, 4096]);
bimds = blockedImageDatastore(A, "BlockLocationSet", bls);
However, I cannot assess these 4096 x 4096 blocks.
I tried to work with:
>> while hasdata(bimds)
[data, info] = read(bimds);
disp(info);
end
Error using images.blocked.TIFF/getIOBlock (line 139)
Out of memory.
But get the above error message. Is there any possibility that I read in my large image and split it up until my memory is sufficient and then assess the data? I don’t want to use lower resolution, since I am really interested in some specific histological information only reliable visible as highest resolution.
I would be also happy, when I would provide voxel coordinate start and end position and split it up manually such that it fits my RAM. I can do it in python but I would like to work with this dataset in Matlab as well.
Similar to this (which was not working either):
>> img = bigimage(strcat(p,f));
%Starting coordinates
coordStart = [250 250];
%Ending Coordinates
coordEnd = [750,750];
%Extract the region between the aforementioned coordinates
blk1 = getRegion(img,1,coordStart, coordEnd);
%Display the image
bigimageshow(bigimage(blk1))
Error using imread (line 440)
Unable to read TIFF file "SSES-1_MAX.ndpi". File is corrupt or image does not contain any readable strips.
Thanks in advance!I want to read in a very large histological image file (file size: 2.05 GB, *.ndpi file, pixel size: 57856 x 1.111e+05) and don’t have enough RAM.
I tried blockedImage and thought it would fit great but still, I am unable to get my data in highest resolution.
I tried:
% p,f are path and filename for the 2.05 GB *.ndpi file
A = blockedImage(strcat(p,f));
levelSizeInfo = table((1:length(A.Size))’, …
A.Size(:,1), …
A.Size(:,2), …
A.Size(:,1)./A.Size(:,2), …
‘VariableNames’,["Resolution Level" "Image Width" "Image Height" "Aspect Ratio"])
and obtained
levelSizeInfo =
9×4 table
Resolution Level Image Width Image Height Aspect Ratio
________________ ___________ ____________ ____________
1 57856 1.111e+05 0.52074
2 28928 55552 0.52074
3 14464 27776 0.52074
4 7232 13888 0.52074
5 3616 6944 0.52074
6 1808 3472 0.52074
7 904 1736 0.52074
8 407 1188 0.34259
9 203 594 0.34175
So I want to assess the resolution level 1 information and therefore tried to split it up in smaller patches:
bls = selectBlockLocations(A,"Levels",1,"BlockSize",[4096, 4096]);
bimds = blockedImageDatastore(A, "BlockLocationSet", bls);
However, I cannot assess these 4096 x 4096 blocks.
I tried to work with:
>> while hasdata(bimds)
[data, info] = read(bimds);
disp(info);
end
Error using images.blocked.TIFF/getIOBlock (line 139)
Out of memory.
But get the above error message. Is there any possibility that I read in my large image and split it up until my memory is sufficient and then assess the data? I don’t want to use lower resolution, since I am really interested in some specific histological information only reliable visible as highest resolution.
I would be also happy, when I would provide voxel coordinate start and end position and split it up manually such that it fits my RAM. I can do it in python but I would like to work with this dataset in Matlab as well.
Similar to this (which was not working either):
>> img = bigimage(strcat(p,f));
%Starting coordinates
coordStart = [250 250];
%Ending Coordinates
coordEnd = [750,750];
%Extract the region between the aforementioned coordinates
blk1 = getRegion(img,1,coordStart, coordEnd);
%Display the image
bigimageshow(bigimage(blk1))
Error using imread (line 440)
Unable to read TIFF file "SSES-1_MAX.ndpi". File is corrupt or image does not contain any readable strips.
Thanks in advance! I want to read in a very large histological image file (file size: 2.05 GB, *.ndpi file, pixel size: 57856 x 1.111e+05) and don’t have enough RAM.
I tried blockedImage and thought it would fit great but still, I am unable to get my data in highest resolution.
I tried:
% p,f are path and filename for the 2.05 GB *.ndpi file
A = blockedImage(strcat(p,f));
levelSizeInfo = table((1:length(A.Size))’, …
A.Size(:,1), …
A.Size(:,2), …
A.Size(:,1)./A.Size(:,2), …
‘VariableNames’,["Resolution Level" "Image Width" "Image Height" "Aspect Ratio"])
and obtained
levelSizeInfo =
9×4 table
Resolution Level Image Width Image Height Aspect Ratio
________________ ___________ ____________ ____________
1 57856 1.111e+05 0.52074
2 28928 55552 0.52074
3 14464 27776 0.52074
4 7232 13888 0.52074
5 3616 6944 0.52074
6 1808 3472 0.52074
7 904 1736 0.52074
8 407 1188 0.34259
9 203 594 0.34175
So I want to assess the resolution level 1 information and therefore tried to split it up in smaller patches:
bls = selectBlockLocations(A,"Levels",1,"BlockSize",[4096, 4096]);
bimds = blockedImageDatastore(A, "BlockLocationSet", bls);
However, I cannot assess these 4096 x 4096 blocks.
I tried to work with:
>> while hasdata(bimds)
[data, info] = read(bimds);
disp(info);
end
Error using images.blocked.TIFF/getIOBlock (line 139)
Out of memory.
But get the above error message. Is there any possibility that I read in my large image and split it up until my memory is sufficient and then assess the data? I don’t want to use lower resolution, since I am really interested in some specific histological information only reliable visible as highest resolution.
I would be also happy, when I would provide voxel coordinate start and end position and split it up manually such that it fits my RAM. I can do it in python but I would like to work with this dataset in Matlab as well.
Similar to this (which was not working either):
>> img = bigimage(strcat(p,f));
%Starting coordinates
coordStart = [250 250];
%Ending Coordinates
coordEnd = [750,750];
%Extract the region between the aforementioned coordinates
blk1 = getRegion(img,1,coordStart, coordEnd);
%Display the image
bigimageshow(bigimage(blk1))
Error using imread (line 440)
Unable to read TIFF file "SSES-1_MAX.ndpi". File is corrupt or image does not contain any readable strips.
Thanks in advance! histological data, ndpi, blockedimage MATLAB Answers — New Questions
why does this line of code give error- disp(“The density of ” + element … + “is” + density). When i press the ‘enter ‘ key after the 3 dots and rerun, it works.
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp("The Density of " + element … + "is" + density)
endif doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp("The Density of " + element … + "is" + density)
end if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp("The Density of " + element … + "is" + density)
end if statement MATLAB Answers — New Questions
Adding a second x-axis to each plot in a tiled layout / subplot
I am trying to add a second x-axis to each plot in a tiled layout. Using this tutorial, I was able to add a second x-axis to the first tile. However, as soon as I transition to the next tile, the previous plot disappears and I am just left with a single blank plot. Adding "hold on" to any line in the code didn’t help, neither did plotting the same data a second time. The same problem arises when using subplot().
I would greatly appreciate any help! My code looks like this (I only need the second axis in order to display different x-ticks w.r.t. to the same data, which is why I’m not adding any plots to the second axis):
% create tiledlayout
tiledlayout(2, 2)
nexttile
% plot toy example
hold on
plot(0:10, 0:10)
axis([0 10 0 10])
xticks([2 7])
% add second axis
ax1 = gca;
ax2 = axes(‘Position’, ax1.Position, ‘XAxisLocation’, ‘top’, ‘YAxisLocation’,’right’, ‘Color’,’none’);
axis([0 10 0 10])
xticks([1 8])
% after this line, the plot disappears
nexttileI am trying to add a second x-axis to each plot in a tiled layout. Using this tutorial, I was able to add a second x-axis to the first tile. However, as soon as I transition to the next tile, the previous plot disappears and I am just left with a single blank plot. Adding "hold on" to any line in the code didn’t help, neither did plotting the same data a second time. The same problem arises when using subplot().
I would greatly appreciate any help! My code looks like this (I only need the second axis in order to display different x-ticks w.r.t. to the same data, which is why I’m not adding any plots to the second axis):
% create tiledlayout
tiledlayout(2, 2)
nexttile
% plot toy example
hold on
plot(0:10, 0:10)
axis([0 10 0 10])
xticks([2 7])
% add second axis
ax1 = gca;
ax2 = axes(‘Position’, ax1.Position, ‘XAxisLocation’, ‘top’, ‘YAxisLocation’,’right’, ‘Color’,’none’);
axis([0 10 0 10])
xticks([1 8])
% after this line, the plot disappears
nexttile I am trying to add a second x-axis to each plot in a tiled layout. Using this tutorial, I was able to add a second x-axis to the first tile. However, as soon as I transition to the next tile, the previous plot disappears and I am just left with a single blank plot. Adding "hold on" to any line in the code didn’t help, neither did plotting the same data a second time. The same problem arises when using subplot().
I would greatly appreciate any help! My code looks like this (I only need the second axis in order to display different x-ticks w.r.t. to the same data, which is why I’m not adding any plots to the second axis):
% create tiledlayout
tiledlayout(2, 2)
nexttile
% plot toy example
hold on
plot(0:10, 0:10)
axis([0 10 0 10])
xticks([2 7])
% add second axis
ax1 = gca;
ax2 = axes(‘Position’, ax1.Position, ‘XAxisLocation’, ‘top’, ‘YAxisLocation’,’right’, ‘Color’,’none’);
axis([0 10 0 10])
xticks([1 8])
% after this line, the plot disappears
nexttile subplot, tiledlayout, axis MATLAB Answers — New Questions
Get the frequencies at specific value of amplitude
Hello everyone, I want to split the signal using the Gabor transform and then taking the values of frequency against the maximum value of amplitude within each window. Thank you for helping me.Hello everyone, I want to split the signal using the Gabor transform and then taking the values of frequency against the maximum value of amplitude within each window. Thank you for helping me. Hello everyone, I want to split the signal using the Gabor transform and then taking the values of frequency against the maximum value of amplitude within each window. Thank you for helping me. gabor, fft, frequency, psd, signal processing, signal MATLAB Answers — New Questions
Maybe a mistake in the documentation of function ”robgain”
Please refer to this documentation: robgain
as well as this system:
In the example "Robust Performance of Closed-Loop System", it says that "Create a model of the controller, and build the closed-loop sensitivity function, S. The sensitivity measures the closed-loop response at the plant output to a disturbance at the plant input."
The corresponding codes are:
k = ureal(‘k’,10,’Percent’,40);
delta = ultidyn(‘delta’,[1 1]);
G = tf(18,[1 1.8 k]) * (1 + 0.5*delta);
C = pid(2.3,3,0.38,0.001);
S = feedback(1,G*C);
tf(S)
However, when I refer to the documentation of feedback, it seems that the code feedback(1,G*C) actually refers to the closed-loop response at the plant input, instead of that at the plant output. I use the function connect to prove this:
G.InputName = ‘e2’;
G.OutputName = ‘y’;
C.InputName = ‘e1’;
C.OutputName = ‘u’;
S1 = sumblk("e1 = r – y");
S2 = sumblk("e2 = u + d");
inputs = {‘d’};
outputs = {‘e2’};
S = connect(G,C,S1,S2,inputs,outputs);
tf(S)
The preceding two results are the same, which prove my assumption.
To measure the closed-loop response at the plant output to a disturbance at the plant input, the codes should be:
S = feedback(G,C);
tf(S)
or in the "connect" version
G.InputName = ‘e2’;
G.OutputName = ‘y’;
C.InputName = ‘e1’;
C.OutputName = ‘u’;
S1 = sumblk("e1 = r – y");
S2 = sumblk("e2 = u + d");
inputs = {‘d’};
outputs = {‘y’};
S = connect(G,C,S1,S2,inputs,outputs);
tf(S)
Please check other documentatins which also use this sensitivity function.
Best regards.Please refer to this documentation: robgain
as well as this system:
In the example "Robust Performance of Closed-Loop System", it says that "Create a model of the controller, and build the closed-loop sensitivity function, S. The sensitivity measures the closed-loop response at the plant output to a disturbance at the plant input."
The corresponding codes are:
k = ureal(‘k’,10,’Percent’,40);
delta = ultidyn(‘delta’,[1 1]);
G = tf(18,[1 1.8 k]) * (1 + 0.5*delta);
C = pid(2.3,3,0.38,0.001);
S = feedback(1,G*C);
tf(S)
However, when I refer to the documentation of feedback, it seems that the code feedback(1,G*C) actually refers to the closed-loop response at the plant input, instead of that at the plant output. I use the function connect to prove this:
G.InputName = ‘e2’;
G.OutputName = ‘y’;
C.InputName = ‘e1’;
C.OutputName = ‘u’;
S1 = sumblk("e1 = r – y");
S2 = sumblk("e2 = u + d");
inputs = {‘d’};
outputs = {‘e2’};
S = connect(G,C,S1,S2,inputs,outputs);
tf(S)
The preceding two results are the same, which prove my assumption.
To measure the closed-loop response at the plant output to a disturbance at the plant input, the codes should be:
S = feedback(G,C);
tf(S)
or in the "connect" version
G.InputName = ‘e2’;
G.OutputName = ‘y’;
C.InputName = ‘e1’;
C.OutputName = ‘u’;
S1 = sumblk("e1 = r – y");
S2 = sumblk("e2 = u + d");
inputs = {‘d’};
outputs = {‘y’};
S = connect(G,C,S1,S2,inputs,outputs);
tf(S)
Please check other documentatins which also use this sensitivity function.
Best regards. Please refer to this documentation: robgain
as well as this system:
In the example "Robust Performance of Closed-Loop System", it says that "Create a model of the controller, and build the closed-loop sensitivity function, S. The sensitivity measures the closed-loop response at the plant output to a disturbance at the plant input."
The corresponding codes are:
k = ureal(‘k’,10,’Percent’,40);
delta = ultidyn(‘delta’,[1 1]);
G = tf(18,[1 1.8 k]) * (1 + 0.5*delta);
C = pid(2.3,3,0.38,0.001);
S = feedback(1,G*C);
tf(S)
However, when I refer to the documentation of feedback, it seems that the code feedback(1,G*C) actually refers to the closed-loop response at the plant input, instead of that at the plant output. I use the function connect to prove this:
G.InputName = ‘e2’;
G.OutputName = ‘y’;
C.InputName = ‘e1’;
C.OutputName = ‘u’;
S1 = sumblk("e1 = r – y");
S2 = sumblk("e2 = u + d");
inputs = {‘d’};
outputs = {‘e2’};
S = connect(G,C,S1,S2,inputs,outputs);
tf(S)
The preceding two results are the same, which prove my assumption.
To measure the closed-loop response at the plant output to a disturbance at the plant input, the codes should be:
S = feedback(G,C);
tf(S)
or in the "connect" version
G.InputName = ‘e2’;
G.OutputName = ‘y’;
C.InputName = ‘e1’;
C.OutputName = ‘u’;
S1 = sumblk("e1 = r – y");
S2 = sumblk("e2 = u + d");
inputs = {‘d’};
outputs = {‘y’};
S = connect(G,C,S1,S2,inputs,outputs);
tf(S)
Please check other documentatins which also use this sensitivity function.
Best regards. robust control toolbox, control, help, robgain MATLAB Answers — New Questions
creating a function to solve non linear equations using simple iteration method
Create a Matlab function named (solveIteration) for solving a non-linear equation using
(Simple iteration method) and takes the following inputs: g: function, x0 initial guess TolX as
Termination tolerance on the function value, a positive scalar (when to stop iteration) and
Maxiter as the max number of iterations if reached means the function has no solution
The function returns the following outputs : x as a root(s) of the equation ,error as error
message if the equation has no solutions
Function seems like below one:
function [x,error] = solveIteration(g,x0,TolX,MaxIter)
…
any hints ??Create a Matlab function named (solveIteration) for solving a non-linear equation using
(Simple iteration method) and takes the following inputs: g: function, x0 initial guess TolX as
Termination tolerance on the function value, a positive scalar (when to stop iteration) and
Maxiter as the max number of iterations if reached means the function has no solution
The function returns the following outputs : x as a root(s) of the equation ,error as error
message if the equation has no solutions
Function seems like below one:
function [x,error] = solveIteration(g,x0,TolX,MaxIter)
…
any hints ?? Create a Matlab function named (solveIteration) for solving a non-linear equation using
(Simple iteration method) and takes the following inputs: g: function, x0 initial guess TolX as
Termination tolerance on the function value, a positive scalar (when to stop iteration) and
Maxiter as the max number of iterations if reached means the function has no solution
The function returns the following outputs : x as a root(s) of the equation ,error as error
message if the equation has no solutions
Function seems like below one:
function [x,error] = solveIteration(g,x0,TolX,MaxIter)
…
any hints ?? numeric equation solving MATLAB Answers — New Questions
Boxplot for both x and y axis with different box widths.
How can we make a boxplot like the one below for both x and y data (the box widths of each group that are x-data related are different). I tried boxplot(X,Y, group) but it did not work.How can we make a boxplot like the one below for both x and y data (the box widths of each group that are x-data related are different). I tried boxplot(X,Y, group) but it did not work. How can we make a boxplot like the one below for both x and y data (the box widths of each group that are x-data related are different). I tried boxplot(X,Y, group) but it did not work. boxplot, different box width MATLAB Answers — New Questions
In R2024a, when searching for components using Chinese after double clicking on the Simulink interface, it will get stuck
This issue is causing me a lot of trouble when using Simulink, and I hope it can be resolved. There is no such issue in 2020b, and there is no such issue when searching in English in 2024a.This issue is causing me a lot of trouble when using Simulink, and I hope it can be resolved. There is no such issue in 2020b, and there is no such issue when searching in English in 2024a. This issue is causing me a lot of trouble when using Simulink, and I hope it can be resolved. There is no such issue in 2020b, and there is no such issue when searching in English in 2024a. r2024a, simulink, search MATLAB Answers — New Questions
Speeding up matrix expotentials by using GPU
Hey all:
I am trying to accelerate the speed of calculation of high dimisional matrix expotential by using GPU, but I find that the speed of calculating them on CPU is faster than GPU, and I can’t find where the problem is. The code is:
dev = gpuDevice();
CPU_time = 0;
GPU_time = 0;
for i = 1:10
CPU_matrix = rand(4096, 4096);
GPU_matrix = gpuArray(complex(CPU_matrix));
tic;
Exp_CPU = expm(-1i * CPU_matrix);
CPU_time = CPU_time + toc;
tic;
Exp_GPU = expm(-1i * GPU_matrix);
GPU_time = GPU_time + toc;
end
disp("CPU time:" + string(CPU_time));
disp("GPU time:" + string(GPU_time));
I tested this code using my computer, and its CPU configuration is: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz, RAM 16 GB. Its GPU configuration is: NVIDIA GeForce GTX 1650. The final result is:
CPU time:452.1338
GPU time:915.5892
Why the speed of GPU is slower than CPU?
ThanksHey all:
I am trying to accelerate the speed of calculation of high dimisional matrix expotential by using GPU, but I find that the speed of calculating them on CPU is faster than GPU, and I can’t find where the problem is. The code is:
dev = gpuDevice();
CPU_time = 0;
GPU_time = 0;
for i = 1:10
CPU_matrix = rand(4096, 4096);
GPU_matrix = gpuArray(complex(CPU_matrix));
tic;
Exp_CPU = expm(-1i * CPU_matrix);
CPU_time = CPU_time + toc;
tic;
Exp_GPU = expm(-1i * GPU_matrix);
GPU_time = GPU_time + toc;
end
disp("CPU time:" + string(CPU_time));
disp("GPU time:" + string(GPU_time));
I tested this code using my computer, and its CPU configuration is: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz, RAM 16 GB. Its GPU configuration is: NVIDIA GeForce GTX 1650. The final result is:
CPU time:452.1338
GPU time:915.5892
Why the speed of GPU is slower than CPU?
Thanks Hey all:
I am trying to accelerate the speed of calculation of high dimisional matrix expotential by using GPU, but I find that the speed of calculating them on CPU is faster than GPU, and I can’t find where the problem is. The code is:
dev = gpuDevice();
CPU_time = 0;
GPU_time = 0;
for i = 1:10
CPU_matrix = rand(4096, 4096);
GPU_matrix = gpuArray(complex(CPU_matrix));
tic;
Exp_CPU = expm(-1i * CPU_matrix);
CPU_time = CPU_time + toc;
tic;
Exp_GPU = expm(-1i * GPU_matrix);
GPU_time = GPU_time + toc;
end
disp("CPU time:" + string(CPU_time));
disp("GPU time:" + string(GPU_time));
I tested this code using my computer, and its CPU configuration is: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz, RAM 16 GB. Its GPU configuration is: NVIDIA GeForce GTX 1650. The final result is:
CPU time:452.1338
GPU time:915.5892
Why the speed of GPU is slower than CPU?
Thanks gpu, matrix, matlab, time, expotential MATLAB Answers — New Questions