Javascript to MATLAB code conversion
39 views (last 30 days)
Show older comments
Hello,
A javascript code to extract a range of parameter values from HTML files is given at :
How can this code be converted to MATLAB ? Thanks.
1 Comment
Mohammad Sami
on 21 May 2020
You can use regexp to extract the relevant portion of the html. Then use jsondecode function to convert this into a struct.
Answers (1)
Sebastian Avalos Inca
on 28 Sep 2020
convertir a lenguale de programacionde matlab
>
<
head
>
<
title
>
Pago y descuento de una compañía telefónica
title
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
>
<
script
>
function
algoritmo
(
)
{
let
dia
,
turno
;
let
impuestos
,
minutos
,
subtotal
,
total
;
minutos
=
parseFloat
(
document.
formulario1
.
minutos
.
value
)
;
dia
=
parseInt
(
document.
formulario1
.
dia
.
value
)
;
turno
=
parseInt
(
document.
formulario1
.
turno
.
value
)
;
subtotal
=
0
;
if
(
minutos
<=
5
)
subtotal
=
minutos
;
if
(
minutos
>
5
&&
minutos
<=
8
)
subtotal
=
5.0
+
(
minutos
-
5
)
*
0.8
;
if
(
minutos
>
8
&&
minutos
<=
10
)
subtotal
=
5.0
+
3.0
*
0.8
+
(
minutos
-
8
)
*
0.7
;
if
(
minutos
>
10
)
subtotal
=
5.0
+
3.0
*
0.8
+
2.0
*
0.7
+
(
minutos
-
10
)
*
0.5
;
impuestos
=
0
;
if
(
dia
==
1
)
impuestos
=
subtotal
*
0.03
;
if
(
dia
==
2
&&
turno
==
1
)
impuestos
=
subtotal
*
0.15
;
if
(
dia
==
2
&&
turno
==
1
)
impuestos
=
subtotal
*
0.1
;
total
=
subtotal
+
impuestos
;
document.
formulario1
.
impuestos
.
value
=
impuestos
;
document.
formulario1
.
subtotal
.
value
=
subtotal
;
document.
formulario1
.
total
.
value
=
total
;
}
script
>
head
>
<
body
>
<
form
name
=
"formulario1"
>
<
table
style
=
"text-align: left; margin-left: auto; margin-right: auto;"
>
<
tbody
>
<
tr
>
<
td
>
<
label
for
=
"minutos"
>
Ingrese el valor de minutos:
label
>
td
>
<
td
>
<
input
name
=
"minutos"
required
=
"required"
step
=
"0.000001"
type
=
"number"
/>
td
>
tr
>
<
tr
>
<
td
>
<
label
for
=
"dia"
>
Seleccione el valor de dia:
label
>
td
>
<
td
>
<
select
name
=
"dia"
required
=
"required"
>
<
option
value
=
"1"
>
domingo
option
>
<
option
value
=
"2"
>
h
á
bil
option
>
<
option
value
=
"3"
>
inh
á
bil
option
>
select
>
td
>
tr
>
<
tr
>
<
td
>
<
label
for
=
"turno"
>
Seleccione el valor de turno:
label
>
td
>
<
td
>
<
select
name
=
"turno"
required
=
"required"
>
<
option
value
=
"1"
>
matutino
option
>
<
option
value
=
"2"
>
vespertino
option
>
select
>
td
>
tr
>
<
tr
align
=
"center"
>
<
td
colspan
=
"2"
rowspan
=
"1"
>
<
input
value
=
"Procesar"
type
=
"button"
onclick
=
“algoritmo ();"
/>
<
input
type
=
"reset"
/>
td
>
tr
>
<
tr
>
<
td
>
<
label
for
=
"impuestos"
>
Valor de impuestos:
label
>
td
>
<
td
>
<
input
name
=
"impuestos"
step
=
"0.000001"
type
=
"number"
/>
td
>
tr
>
<
tr
>
<
td
>
<
label
for
=
"subtotal"
>
Valor de subtotal:
label
>
td
>
<
td
>
<
input
name
=
"subtotal"
step
=
"0.000001"
type
=
"number"
/>
td
>
tr
>
<
tr
>
<
td
>
<
label
for
=
"total"
>
Valor de total:
label
>
td
>
<
td
>
<
input
name
=
"total"
step
=
"0.000001"
type
=
"number"
/>
td
>
tr
>
tbody
>
table
>
form
>
body
>
html
>
4 Comments
Rik
on 29 Sep 2020
Since this isn't your code, why are you opposed to allowing Sebastian to explain why this should stay?
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!